Received: from makus.postgresql.org ([98.129.198.125]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TFKlD-0004PQ-NG for pgsql-sql@postgresql.org; Sat, 22 Sep 2012 08:08:23 +0000 Received: from mailout01.ims-firmen.de ([213.174.32.96]) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TFKlB-0000sF-KO for pgsql-sql@postgresql.org; Sat, 22 Sep 2012 08:08:23 +0000 Received: from mailin01.ims-firmen.de ([192.168.1.141]) by mailout01.ims-firmen.de with esmtp (envelope-from ) id 1TFKl9-0003MR-ik for pgsql-sql@postgresql.org; Sat, 22 Sep 2012 10:08:19 +0200 Received: from [213.174.32.254] (helo=a-kretschmer.de) by mailin01.ims-firmen.de with esmtpsa (TLSv1:AES256-SHA:256) (envelope-from ) id 1TFKl9-0002LQ-1w for pgsql-sql@postgresql.org; Sat, 22 Sep 2012 10:08:19 +0200 Received: from kretschmer by a-kretschmer.de with local (Exim 4.69) (envelope-from ) id 1TFKl7-0000t7-8j for pgsql-sql@postgresql.org; Sat, 22 Sep 2012 10:08:17 +0200 Date: Sat, 22 Sep 2012 10:08:17 +0200 From: Andreas Kretschmer To: pgsql-sql@postgresql.org Subject: Re: matching a timestamp field Message-ID: <20120922080817.GA2943@tux> References: <3C56CD7AD881324BB4C60AA5CE2C5CC11720019A@A04059.BGC.NET> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <3C56CD7AD881324BB4C60AA5CE2C5CC11720019A@A04059.BGC.NET> X-OS: Debian/GNU Linux - weil ich es mir Wert bin! X-GPG-Fingerprint: EE16 3C01 7B9C 10F7 2C8B 3B86 4DB3 D9EE 7F45 84DA X-Message-Flag: "Windows" is not the answer. "Windows" is the question and the answer is "no"! X-Lugdd: Gerd Kube X-Info: My name is root. Just root. And I am licensed to kill -9 User-Agent: Mutt/1.5.18 (2008-05-17) X-Pg-Spam-Score: -1.9 (-) X-Archive-Number: 201209/49 X-Sequence-Number: 36851 BACHELART PIERRE (CIS/SCC) wrote: > Hello, > > > > > > Why is my sql below accepted in 8.1.19 and refused in 8.4.9 ??? > > Welcome to psql 8.1.19, the PostgreSQL interactive terminal. > > ansroc=# select * from s12hwdb where record ~'2012-09-20' limit 5; > > > psql (8.4.9) > > > ERROR: operator does not exist: timestamp without time zone ~ unknown > > LINE 1: select * from s12hwdb where record ~'2012-09-20' limit 5; > Because of the dropped implicid casts since IIRC 8.2. You have to rewrite your query to: select * from s12hwdb where record::date = '2012-09-20'::date limit 5; (assuming record is a TIMESTAMP-Field) Short example: test=# select now() ~ '2012-09-22'; ERROR: operator does not exist: timestamp with time zone ~ unknown LINE 1: select now() ~ '2012-09-22'; ^ HINT: No operator matches the given name and argument type(s). You might need to add explicit type casts. Time: 0,156 ms test=!# rollback; ROLLBACK Time: 0,079 ms test=# select now()::date = '2012-09-22'::date; ?column? ---------- t (1 row) Andreas -- Really, I'm not out to destroy Microsoft. That will just be a completely unintentional side effect. (Linus Torvalds) "If I was god, I would recompile penguin with --enable-fly." (unknown) Kaufbach, Saxony, Germany, Europe. N 51.05082°, E 13.56889°