pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: David W Noon <dwnoon@spamtrap.ntlworld.com>
To: pgsql-sql@postgresql.org
Subject: Re: EASY QUESTION!!
Date: Sun, 27 Apr 2003 11:30:13 +0100
Message-ID: <m2osn-brf.ln1@my-pc.ntlworld.com> (raw)
References: <1cf4c899.0304270003.244d1ce@posting.google.com>

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.
======================================================




view thread (3+ messages)  latest in thread

Message-ID: <m2osn-brf.ln1@my-pc.ntlworld.com>
Permalink:  ../m2osn-brf.ln1@my-pc.ntlworld.com/
Also on:    postgresql.org/message-id/m2osn-brf.ln1@my-pc.ntlworld.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: dwnoon@spamtrap.ntlworld.com
  Subject: Re: EASY QUESTION!!
  In-Reply-To: <m2osn-brf.ln1@my-pc.ntlworld.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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