Re: What day is it - when it isn't NOW()?

From: Josh Berkus <josh(at)agliodbs(dot)com>
To: tomg(at)sqlclinic(dot)net, 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:28:25
Message-ID: 200308011128.25461.josh@agliodbs.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message tomg 2003-08-01 18:53:10 Re: What day is it - when it isn't NOW()?
Previous Message Rod Taylor 2003-08-01 18:28:11 Re: What day is it - when it isn't NOW()?