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

Re: pattern matching with dates?

From: Susanne Ebrecht <susanne(at)2ndQuadrant(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 12:39:47
Message-ID: (view raw, whole thread or download thread mbox)
Lists: 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 Ebrecht - 2ndQuadrant
PostgreSQL Development, 24x7 Support, Training and Services

In response to


pgsql-sql by date

Next:From: pasman pasmańskiDate: 2011-01-07 14:15:03
Subject: Re: pattern matching with dates?
Previous:From: Oliveiros d'Azevedo CristinaDate: 2011-01-07 11:04:53
Subject: Re: return records with more than one occurrences

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