Re: pattern matching with dates? - Mailing list pgsql-sql

From Susanne Ebrecht
Subject Re: pattern matching with dates?
Date
Msg-id 4D270993.302@2ndQuadrant.com
Whole thread Raw
In response to pattern matching with dates?  ("Good, Thomas" <tgood@svcmcny.org>)
Responses Re: pattern matching with dates?
List pgsql-sql
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



pgsql-sql by date:

Previous
From: "Oliveiros d'Azevedo Cristina"
Date:
Subject: Re: return records with more than one occurrences
Next
From: pasman pasmański
Date:
Subject: Re: pattern matching with dates?