Re: pattern matching with dates?

From: pasman pasmański <pasman(dot)p(at)gmail(dot)com>
To: "pgsql-sql(at)postgresql(dot)org" <pgsql-sql(at)postgresql(dot)org>
Subject: Re: pattern matching with dates?
Date: 2011-01-07 14:15:03
Message-ID: AANLkTi=pahSTCHk07nj79KjSoXa8DhqUv5mA7Z3FdcEX@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Sorry, but this examples not use index.

On 1/7/11, Susanne Ebrecht <susanne(at)2ndquadrant(dot)com> wrote:
> Hello Thomas,
>
> On 05.01.2011 20:39, Good, Thomas wrote:
>> select * from db_log where log_date LIKE '2011-01-%';
>
> The lazy way would be something like this:
> SELECT * from tab WHERE log_date::VARCHAR LIKE '2011-01-%';
>
> The more proper way is:
> SELECT * from tab WHERE EXTRACT(YEAR FROM log_date) = 2011 and
> EXTRACT(MONTH FROM log_date) = 1;
>
> Susanne
>
> --
> Susanne Ebrecht - 2ndQuadrant
> PostgreSQL Development, 24x7 Support, Training and Services
> www.2ndQuadrant.com
>
>
> --
> Sent via pgsql-sql mailing list (pgsql-sql(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-sql
>

--
Sent from my mobile device

------------
pasman

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Richard Huxton 2011-01-07 16:09:50 Re: pattern matching with dates?
Previous Message Susanne Ebrecht 2011-01-07 12:39:47 Re: pattern matching with dates?