X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (neptune.hub.org [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id F1DC9D1B49E for ; Wed, 10 Dec 2003 05:52:45 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 87758-08 for ; Wed, 10 Dec 2003 01:52:15 -0400 (AST) Received: from ns.tirupati.biz (unknown [64.239.5.38]) by svr1.postgresql.org (Postfix) with SMTP id 74DCFD1B444 for ; Wed, 10 Dec 2003 01:52:13 -0400 (AST) Received: (qmail 27296 invoked from network); 10 Dec 2003 05:51:20 -0000 Received: from softdnserror (HELO server2k) (61.11.69.140) by web-hosting-india.ebizindia.com with SMTP; 10 Dec 2003 05:51:20 -0000 Received: from 192.168.50.15 by server2k ([192.168.50.102] running VPOP3) with SMTP; Wed, 10 Dec 2003 11:26:23 +0530 X-MSReally-From: sqllist@coralindia.com Message-ID: <002101c3bede$ed1e29e0$0f32a8c0@denisnew> From: "sqllist" To: Cc: References: Subject: Re: How to specify the beginning of the month in Postgres SQL syntax? Date: Wed, 10 Dec 2003 11:01:54 +0530 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2600.0000 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 X-Server: VPOP3 V1.5.0 - Registered X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200312/79 X-Sequence-Number: 16245 Hi Jeff, You can use WHERE date < to_date( to_char(current_date,'yyyy-MM') || '-01','yyyy-mm-dd') Thanx Denis ----- Original Message ----- From: To: Sent: Sunday, December 07, 2003 9:46 PM Subject: [SQL] How to specify the beginning of the month in Postgres SQL syntax? > Hello, > > I need to create a view in Postgres that has a where clause of the > date < beginning of month. > > i.e.: > SELECT supplier_number, Sum(amount) AS due > FROM purchase_orders > WHERE date < '2003-12-1' AND paid = 0 > GROUP BY supplier_number > ORDER BY supplier_number ASC > > > As you can see, I've specified the 1st of December this year as the > where clause. What I want is an SQL statement that automatically > generates the first of the month. How do I do this? > > Thanks. > > ---------------------------(end of broadcast)--------------------------- > TIP 9: the planner will ignore your desire to choose an index scan if your > joining column's datatypes do not match