From: | tomg(at)sqlclinic(dot)net |
---|---|
To: | Josh Berkus <josh(at)agliodbs(dot)com> |
Cc: | Postgres SQL List <pgsql-sql(at)postgreSQL(dot)org> |
Subject: | Re: What day is it - when it isn't NOW()? |
Date: | 2003-08-01 18:53:10 |
Message-ID: | Pine.LNX.4.44.0308011445250.29369-100000@q8.nrnet.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
On Fri, 1 Aug 2003, Josh Berkus wrote:
> Thomas,
>
> > than now()? I'm looking for something along the lines of:
> > SELECT to_char('2003-08-04', 'Day') without much success.
> >
>
> Well, you could try the online docs under "Functions and operators" <grin>.
Hey Josh, how goes...yeah I bumbled around date/time functions for awhile but
couldn't find the right syntax...maybe I need new glasses? ;-)
> Alternately, SELECT EXTRACT(dow FROM '2003-08-04') will give you a numerical
> (0-6) day of the week.
I tried this but I don't need an integer returned so I went with the
to_char() approach. Thanks for tip - and thanks to Rod as well.
On 1 Aug 2003, Rod Taylor wrote:
>
> SELECT to_char('2003-08-04'::date, 'Day');
>
This is what I went for as it is the closest to the MySQL/Oracle syntax
I use for the same purpose, particularly Oracle:
$query = qq |SELECT DATE_FORMAT('$start_date', '%W')| if ($dbtype eq 'mysql');
$query = qq |SELECT TO_CHAR('start_date'::date, 'Day') if ($dbtype eq 'postgres');
$query = qq |SELECT TO_CHAR(TO_DATE('$start_date'), 'Day') FROM DUAL| if ($dbtype eq 'oracle');
Thanks again fellas - have a nice weekend!
Cheers
-----------------------------------------------------------------------
Thomas Good e-mail: tomg(at)sqlclinic(dot)net
Programmer/Analyst phone: (+1) 718.818.5528
Residential Services fax: (+1) 718.818.5056
Behavioral Health Services, SVCMC-NY mobile: (+1) 917.282.7359
// Welches ist das groessere Verbrechen?
// Massenvernichtungswaffen besitzen oder sie erfinden?
From | Date | Subject | |
---|---|---|---|
Next Message | Robert Treat | 2003-08-01 19:16:56 | Re: TODO item for plpgsql Was Re: obtuse plpgsql function needs |
Previous Message | Josh Berkus | 2003-08-01 18:28:25 | Re: What day is it - when it isn't NOW()? |