Re: matching a timestamp field

Поиск
Список
Период
Сортировка
От Andreas Kretschmer
Тема Re: matching a timestamp field
Дата
Msg-id 20120922080817.GA2943@tux
обсуждение исходный текст
Ответ на matching a timestamp field  ("BACHELART PIERRE (CIS/SCC)" <pierre.bachelart@belgacom.be>)
Список pgsql-sql
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°



В списке pgsql-sql по дате отправления:

Предыдущее
От: "BACHELART PIERRE (CIS/SCC)"
Дата:
Сообщение: Re: matching a timestamp field
Следующее
От: Jasen Betts
Дата:
Сообщение: Re: Problem with committing the update