From: | Andreas Kretschmer <akretschmer(at)spamfence(dot)net> |
---|---|
To: | pgsql-sql(at)postgresql(dot)org |
Subject: | Re: matching a timestamp field |
Date: | 2012-09-22 08:08:17 |
Message-ID: | 20120922080817.GA2943@tux |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
BACHELART PIERRE (CIS/SCC) <pierre(dot)bachelart(at)belgacom(dot)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°
From | Date | Subject | |
---|---|---|---|
Next Message | Pavel Stehule | 2012-09-22 08:16:46 | Re: matching a timestamp field |
Previous Message | BACHELART PIERRE (CIS/SCC) | 2012-09-20 12:21:56 | Re: matching a timestamp field |