Skip site navigation (1) Skip section navigation (2)

Re: First day of month, last day of month

From: "Bart Degryse" <Bart(dot)Degryse(at)indicator(dot)be>
To: <pgsql-sql(at)postgresql(dot)org>,"Frank Bax" <fbax(at)sympatico(dot)ca>
Subject: Re: First day of month, last day of month
Date: 2008-04-24 13:11:03
Message-ID: 4810A306.A3DD.0030.0@indicator.be (view raw or flat)
Thread:
Lists: pgsql-sql
select * from mytable where date_trunc('month', mydate) = date_trunc('month', now());


>>> Frank Bax <fbax(at)sympatico(dot)ca> 2008-04-24 15:06 >>>
Nacef LABIDI wrote:
> is there a better method to retrieve all 
> the rows with dates in the current month.


select * from mytable where extract(month from mydate) = extract(month 
from now()) and extract(year from mydate) = extract(year from now());

In response to

pgsql-sql by date

Next:From: A. KretschmerDate: 2008-04-24 13:15:36
Subject: Re: First day of month, last day of month
Previous:From: Frank BaxDate: 2008-04-24 13:06:25
Subject: Re: First day of month, last day of month

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group