Re: How to specify the beginning of the month in Postgres SQL syntax? - Mailing list pgsql-sql

From Tom Lane
Subject Re: How to specify the beginning of the month in Postgres SQL syntax?
Date
Msg-id 6552.1071071508@sss.pgh.pa.us
Whole thread Raw
In response to Re: How to specify the beginning of the month in Postgres SQL syntax?  ("sqllist" <sqllist@coralindia.com>)
List pgsql-sql
"sqllist" <sqllist@coralindia.com> writes:
> WHERE date < to_date( to_char(current_date,'yyyy-MM') || '-01','yyyy-mm-dd')

That seems like the hard way.  Try this:

regression=# select date_trunc('month', now());      date_trunc
------------------------2003-12-01 00:00:00-05
(1 row)
        regards, tom lane


pgsql-sql by date:

Previous
From: DHS Webmaster
Date:
Subject: first of month
Next
From: Tom Lane
Date:
Subject: Re: How to completely move a table to another schema?