Обсуждение: showing weekdays of dates
using sr pgdoc I searched for weekdays and though I found a few results I couldn't parse from information provided how to get weekdays of dates to populate a table in any fashion. When I do more in depth analysis of accumulating data sets, some of the analysis I'd like to do would be for each of the seven weekdays during a period of time. I ended up with a script that does two date calls one for the iso date and the second for weekday number and that script writes out the day's insert statement correctly with the values it figures out and the values I supply. The whole system I have now is for health monitoring blood pressure and blood sugar numbers and that's how my doctor gets my numbers for checking progress. It didn't take long to write, I like to improve it as I learn new things with which I can improve it.
On Fri, Aug 29, 2014 at 12:39 PM, Jude DaShiell <jdashiel@panix.com> wrote: > using sr pgdoc I searched for weekdays and though I found a few results I > couldn't parse from information provided how to get weekdays of dates to > populate a table in any fashion. When I do more in depth analysis of > accumulating data sets, some of the analysis I'd like to do would be for > each of the seven weekdays during a period of time. I ended up with a > script that does two date calls one for the iso date and the second for > weekday number and that script writes out the day's insert statement > correctly with the values it figures out and the values I supply. The whole > system I have now is for health monitoring blood pressure and blood sugar > numbers and that's how my doctor gets my numbers for checking progress. It > didn't take long to write, I like to improve it as I learn new things with > which I can improve it. Not completely following your question but perhaps to_char() function is what you need: ysanalysis=# select to_char(now(), 'Day'); to_char ─────────── Friday http://www.postgresql.org/docs/8.1/static/functions-formatting.html merlin
2014-08-29 19:47 GMT+02:00 Merlin Moncure <mmoncure@gmail.com>: > On Fri, Aug 29, 2014 at 12:39 PM, Jude DaShiell <jdashiel@panix.com> wrote: >> using sr pgdoc I searched for weekdays and though I found a few results I >> couldn't parse from information provided how to get weekdays of dates to >> populate a table in any fashion. When I do more in depth analysis of >> accumulating data sets, some of the analysis I'd like to do would be for >> each of the seven weekdays during a period of time. I ended up with a >> script that does two date calls one for the iso date and the second for >> weekday number and that script writes out the day's insert statement >> correctly with the values it figures out and the values I supply. The whole >> system I have now is for health monitoring blood pressure and blood sugar >> numbers and that's how my doctor gets my numbers for checking progress. It >> didn't take long to write, I like to improve it as I learn new things with >> which I can improve it. > > Not completely following your question but perhaps to_char() function > is what you need: > > ysanalysis=# select to_char(now(), 'Day'); > to_char > ─────────── > Friday > > http://www.postgresql.org/docs/8.1/static/functions-formatting.html select to_char(date '2014-08-19','TMDay'); This gives the weekday name in locale that you have setup on your operating system. -- Regards from Pal
this may help, originally I wanted the Day string to write out once a date
was entered followed by remaining fields. That will not work now given
current structure of the health table.
cut here.
create table health (
date date PRIMARY KEY,
Cystalic_Pressure int NOT NULL, check (Cystalic_Pressure > 0),
--- cystalic pressure
Dyastalic_Pressure int NOT NULL, check (Dyastalic_Pressure > 0),
--- dyastalic pressure
Pulse int NOT NULL, check (Pulse > 0),
--- pulse
Blood_Sugar int NOT NULL, check (Blood_Sugar > 0),
--- blood sugar
weekday int NOT NULL, check (weekday > -1), check (weekday < 7)
--- weekday number saturday=6
);
cut here.
#!/usr/bin/env bash
# file: uhealth.sh - update ahealth.sql
# last update: 2014-08-02
f1=`date -I`
echo -n "enter cystalic: "
read f2
echo -n "enter dyastalic: "
read f3
echo -n "enter pulse: "
read f4
echo -n "enter blood sugar: "
read f5
f6=`date '+%w'`
echo "insert into health values ('$f1',$f2,$f3,$f4,$f5,$f6);" >>ahealth.sql
On Fri, 29 Aug 2014, Merlin Moncure wrote:
> On Fri, Aug 29, 2014 at 12:39 PM, Jude DaShiell <jdashiel@panix.com> wrote:
>> using sr pgdoc I searched for weekdays and though I found a few results I
>> couldn't parse from information provided how to get weekdays of dates to
>> populate a table in any fashion. When I do more in depth analysis of
>> accumulating data sets, some of the analysis I'd like to do would be for
>> each of the seven weekdays during a period of time. I ended up with a
>> script that does two date calls one for the iso date and the second for
>> weekday number and that script writes out the day's insert statement
>> correctly with the values it figures out and the values I supply. The whole
>> system I have now is for health monitoring blood pressure and blood sugar
>> numbers and that's how my doctor gets my numbers for checking progress. It
>> didn't take long to write, I like to improve it as I learn new things with
>> which I can improve it.
>
> Not completely following your question but perhaps to_char() function
> is what you need:
>
> ysanalysis=# select to_char(now(), 'Day');
> to_char
> ???????????
> Friday
>
> http://www.postgresql.org/docs/8.1/static/functions-formatting.html
>
> merlin
>
>
>