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

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "sqllist" <sqllist(at)coralindia(dot)com>
Cc: pgsql-sql(at)postgresql(dot)org, jeff(at)dnuk(dot)com
Subject: Re: How to specify the beginning of the month in Postgres SQL syntax?
Date: 2003-12-10 15:51:48
Message-ID: 6552.1071071508@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

"sqllist" <sqllist(at)coralindia(dot)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

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Tom Lane 2003-12-10 16:12:16 Re: How to completely move a table to another schema?
Previous Message DHS Webmaster 2003-12-10 14:20:28 first of month