Re: What day is it - when it isn't NOW()? - Mailing list pgsql-sql

From Josh Berkus
Subject Re: What day is it - when it isn't NOW()?
Date
Msg-id 200308011128.25461.josh@agliodbs.com
Whole thread Raw
In response to What day is it - when it isn't NOW()?  (tomg@sqlclinic.net)
Responses Re: What day is it - when it isn't NOW()?  (tomg@sqlclinic.net)
List pgsql-sql
Thomas,

> SELECT to_char(now(), 'Day');  returns Friday as I'd hoped.
> But how do I return the day of the week for a specific date other
> than now()?  I'm looking for something along the lines of:
> SELECT to_char('2003-08-04', 'Day') without much success.
>
> Can anyone point me to the right function/combination of functions
> to achieve this?

Well, you could try the online docs under "Functions and operators" <grin>.

Two possibilities:

SELECT to_char('2003-08-04'::TIMESTAMP, 'Day') should make the to_char version 
work for you.

Alternately, SELECT EXTRACT(dow FROM '2003-08-04') will give you a numerical 
(0-6) day of the week.

-- 
Josh Berkus
Aglio Database Solutions
San Francisco


pgsql-sql by date:

Previous
From: Rod Taylor
Date:
Subject: Re: What day is it - when it isn't NOW()?
Next
From: tomg@sqlclinic.net
Date:
Subject: Re: What day is it - when it isn't NOW()?