pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
EASY QUESTION!!
3+ messages / 3 participants
[nested] [flat]

* EASY QUESTION!!
@ 2003-04-27 08:03  dvsangel <dvsangel@dodo.com.au>
  0 siblings, 2 replies; 3+ messages in thread

From: dvsangel@dodo.com.au @ 2003-04-27 08:03 UTC (permalink / raw)
  To: pgsql-sql

a column in one of my tables contains dates in the format yyyy-mm-dd
From these dates I need to find out which dates are sundays.
can anyone help me????
PLEASE???




^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: EASY QUESTION!!
@ 2003-04-27 10:30  David W Noon <dwnoon@spamtrap.ntlworld.com>
  parent: dvsangel <dvsangel@dodo.com.au>
  1 sibling, 0 replies; 3+ messages in thread

From: David W Noon @ 2003-04-27 10:30 UTC (permalink / raw)
  To: pgsql-sql

On Sunday 27 Apr 2003 09:03 in
<1cf4c899.0304270003.244d1ce@posting.google.com>, dvsangel
(dvsangel@dodo.com.au) wrote:

> a column in one of my tables contains dates in the format yyyy-mm-dd
> From these dates I need to find out which dates are sundays.

I assume that the column is a DATE rather than a CHAR(10).

If so, the EXTRACT(DOW FROM ...) function should give you what you want. A
value of 0 means Sunday.

If your column is actually a CHAR(10) then coerce it to being a DATE as you
invoke EXTRACT() as above. YMMV.

For example:

SELECT * FROM some_table
   WHERE EXTRACT(DOW FROM date_column) = 0;

or:

SELECT * FROM some_table
   WHERE EXTRACT(DOW FROM CAST(char_column AS DATE)) = 0;

See section 4.8.1 in the PostgreSQL User's Guide for more details. [At least
that's where it is in my copy.]

-- 
Regards,

Dave
======================================================
dwnoon@spamtrap.ntlworld.com (David W Noon)
Remove spam trap to reply via e-mail.
======================================================




^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: EASY QUESTION!!
@ 2003-04-30 20:41  Josh Berkus <josh@agliodbs.com>
  parent: dvsangel <dvsangel@dodo.com.au>
  1 sibling, 0 replies; 3+ messages in thread

From: Josh Berkus @ 2003-04-30 20:41 UTC (permalink / raw)
  To: dvsangel@dodo.com.au; pgsql-sql

DVS,

> a column in one of my tables contains dates in the format yyyy-mm-dd
> From these dates I need to find out which dates are sundays.
> can anyone help me????
> PLEASE???

SELECT extract(dow from <date field>)

I believe that 0 is sunday.

-- 
-Josh Berkus
 Aglio Database Solutions
 San Francisco




^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2003-04-30 20:41 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2003-04-27 08:03 EASY QUESTION!! dvsangel <dvsangel@dodo.com.au>
2003-04-27 10:30 ` David W Noon <dwnoon@spamtrap.ntlworld.com>
2003-04-30 20:41 ` Josh Berkus <josh@agliodbs.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox