Re: First day of month, last day of month

From: Frank Bax <fbax(at)sympatico(dot)ca>
To: pgsql-sql(at)postgresql(dot)org
Subject: Re: First day of month, last day of month
Date: 2008-04-24 13:16:03
Message-ID: 48108813.6070401@sympatico.ca
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Frank Bax wrote:
> 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());

Sorry; I was not thinking clearly - date_trunc is better for this:

select * from mytable where date_trunc('month',mydate) =
date_trunc('month',now());

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Anoop G 2008-04-24 13:34:50 How I can check a substring is a valid number in postgresql ?
Previous Message A. Kretschmer 2008-04-24 13:15:36 Re: First day of month, last day of month