How to specify the beginning of the month in Postgres SQL syntax?

From: jeff(at)dnuk(dot)com
To: pgsql-sql(at)postgresql(dot)org
Subject: How to specify the beginning of the month in Postgres SQL syntax?
Date: 2003-12-07 16:16:44
Message-ID: t6k6tv8unr1dm7kpeb275ca0t9in2i910h@4ax.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

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.

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message CoL 2003-12-07 19:38:53 Re: How to specify the beginning of the month in Postgres SQL syntax?
Previous Message Greg Stark 2003-12-07 00:36:40 Re: Index not recognized