Re: Extract between year *and* month

From: "Syl" <david(dot)hunter(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Extract between year *and* month
Date: 2006-11-30 20:21:08
Message-ID: 1164918068.586197.174450@j44g2000cwa.googlegroups.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


Alban Hertroys wrote:
> Syl wrote:
> >> Try
> >>
> >> select *
> >> from tablename
> >> where title like ('%nith%')
> >> and date_trunc('month',recall_date::timestamp) >= date_trunc('month','1995-01-01'::timestamp)
> >> and date_trunc('month',recall_date::timestamp) <= date_trunc('month','2006-12-31'::timestamp)
> >> order by recall_date
> >>
>
> Actually, that looks a lot like BETWEEN, which is even shorter :)
>
> select *
> from tablename
> where title like ('%nith%')
> and date_trunc('month',recall_date::timestamp)
> between date_trunc('month','1995-01-01'::timestamp)
> and date_trunc('month','2006-12-31'::timestamp)
> order by recall_date
>
>
> > Fantastic.
> >
> > Thank you to Matthias and Russell - everything is working perfectly!
>

Thank you for the accurate and detailed repsonses! All is working
excellent.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Bill Bartlett 2006-11-30 20:23:29 Any issues w/PostgreSQL 8.0.4 on Win2K3 x64?
Previous Message Martijn van Oosterhout 2006-11-30 20:11:10 Re: Ident authentication failed for user "dsivam"