From: Andreas Kretschmer <akretschmer@spamfence.net>
To: pgsql-sql@postgresql.org
Subject: Re: matching a timestamp field
Date: Sat, 22 Sep 2012 10:08:17 +0200
Message-ID: <20120922080817.GA2943@tux> (raw)
In-Reply-To: <3C56CD7AD881324BB4C60AA5CE2C5CC11720019A@A04059.BGC.NET>
References: <3C56CD7AD881324BB4C60AA5CE2C5CC11720019A@A04059.BGC.NET>
BACHELART PIERRE (CIS/SCC) <pierre.bachelart@belgacom.be> 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°
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: akretschmer@spamfence.net
Subject: Re: matching a timestamp field
In-Reply-To: <20120922080817.GA2943@tux>
* 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