From: Susanne Ebrecht <susanne@2ndQuadrant.com>
To: pgsql-sql@postgresql.org <pgsql-sql@postgresql.org>
Subject: Re: pattern matching with dates?
Date: Fri, 07 Jan 2011 13:39:47 +0100
Message-ID: <4D270993.302@2ndQuadrant.com> (raw)
In-Reply-To: <FA041D403EDFCD4397E1F6382360ECFCFDB5697143@SVCMCEMAIL.svcmc.svcmcny.org>
References: <FA041D403EDFCD4397E1F6382360ECFCFDB5697143@SVCMCEMAIL.svcmc.svcmcny.org>
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: susanne@2ndQuadrant.com
Subject: Re: pattern matching with dates?
In-Reply-To: <4D270993.302@2ndQuadrant.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox