Re: problem with selects based on dates

Поиск
Список
Период
Сортировка
От Szabo Zoltan
Тема Re: problem with selects based on dates
Дата
Msg-id 3B989FF4.59BB03F1@econet.hu
обсуждение исходный текст
Ответ на Re: problem with selects based on dates  ("J.H.M. Dassen (Ray)" <jdassen@cistron.nl>)
Список pgsql-general
Hi,

"J.H.M. Dassen (Ray)" wrote:

> Mike Withers <M.withers@uws.edu.au> wrote:
> > db2001=# SELECT * FROM emp WHERE hiredate > 1981-01-01;
>                                               ^^^^^^^^^^
>
> > It is not clear to me why in the last query the 1980-12-17 hiredate record
> > is selected as well.
>
> There are no quotes around what you intend to be the date. Thus it is
> evaluated as an expression, resulting in 1979. Try
>         SELECT * FROM emp WHERE hiredate > '1981-01-01';

But better to use:  to_date( '1981-01-01','YYYY-MM-DD')
SELECT * FROM emp WHERE hiredate > to_date( '1981-01-01','YYYY-MM-DD')

CoL


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

Предыдущее
От: "Ligia Pimentel"
Дата:
Сообщение: Blob datatype / image storing in postgres
Следующее
От: "Marc Lambrichs"
Дата:
Сообщение: enumeration datatype in postgresql?