Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id A35A91337BC1 for ; Fri, 7 Jan 2011 08:40:06 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.29]) (amavisd-maia, port 10024) with ESMTP id 21051-01 for ; Fri, 7 Jan 2011 12:39:58 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from outmail149112.authsmtp.co.uk (outmail149112.authsmtp.co.uk [62.13.149.112]) by mail.postgresql.org (Postfix) with ESMTP id 7405A13364DE for ; Fri, 7 Jan 2011 08:39:56 -0400 (AST) Received: from mail-c193.authsmtp.com (mail-c193.authsmtp.com [62.13.128.118]) by punt3.authsmtp.com (8.14.2/8.14.2/Kp) with ESMTP id p07CdusZ023207 for ; Fri, 7 Jan 2011 12:39:56 GMT Received: from [192.168.23.4] (212.100.42.202.fixip.bitel.net [212.100.42.202]) (authenticated bits=0) by mail.authsmtp.com (8.14.2/8.14.2) with ESMTP id p07CdqLB019888 for ; Fri, 7 Jan 2011 12:39:52 GMT Message-ID: <4D270993.302@2ndQuadrant.com> Date: Fri, 07 Jan 2011 13:39:47 +0100 From: Susanne Ebrecht User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.13) Gecko/20101208 Thunderbird/3.1.7 MIME-Version: 1.0 To: "pgsql-sql@postgresql.org" Subject: Re: pattern matching with dates? References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Server-Quench: 3959ac59-1a5b-11e0-97bb-002264978518 X-AuthReport-Spam: If SPAM / abuse - report it at: http://www.authsmtp.com/abuse X-AuthRoute: OCdxZQATClZOUR8T DCUJJHVGRTw4LxFW CBkfawBdJUwRWh9I NgNBN157KFoHWV5D ViVKB0oLEgo/WWRq EVsPcgddY0teXgdg U0FDR1AcFgRqHx0B BgAaUAdwdwdZentv ZQgiXncoCAUGB0Z8 S0ZcHSMHZW9jJmMW VUkJJAZdbQIbe01Y a1EqVG4EZjdVe3pg RVVtY2FubWgGeDJv T1NFHmkrZXNDBjcg Wx0YG30qFFEORyQ1 IFQ5K0IcVEoYLkgp ZjOE X-Authentic-SMTP: 61633235383639.1014:706 X-AuthFastPath: 255 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.9 tagged_above=-5 required=5 tests=BAYES_00=-1.9 X-Spam-Level: X-Archive-Number: 201101/17 X-Sequence-Number: 34964 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