X-Original-To: pgsql-sql@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id EEDDD475AE5 for ; Sun, 27 Apr 2003 06:39:53 -0400 (EDT) Received: from news.hub.org (news.hub.org [64.49.215.80]) by postgresql.org (Postfix) with ESMTP id 60C42474E42 for ; Sun, 27 Apr 2003 06:39:53 -0400 (EDT) Received: by news.hub.org (Postfix, from userid 8) id 3DF1643A89E; Sun, 27 Apr 2003 06:39:53 -0400 (EDT) Message-ID: From: David W Noon Subject: Re: EASY QUESTION!! X-Newsgroups: comp.databases.postgresql.sql References: <1cf4c899.0304270003.244d1ce@posting.google.com> Lines: 36 User-Agent: KNode/0.7.2 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7Bit Date: Sun, 27 Apr 2003 11:30:13 +0100 X-Complaints-To: abuse@ntlworld.com Organization: ntl Cablemodem News Service To: pgsql-sql@postgresql.org X-Spam-Status: No, hits=-16.1 required=5.0 tests=BAYES_10,QUOTED_EMAIL_TEXT,REFERENCES, SIGNATURE_SHORT_SPARSE,USER_AGENT autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/457 X-Sequence-Number: 13158 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. ======================================================