Re: How to convert postgres timestamp to date: yyyy-mm-dd

Поиск
Список
Период
Сортировка
От A. Kretschmer
Тема Re: How to convert postgres timestamp to date: yyyy-mm-dd
Дата
Msg-id 20080311185029.GA11998@a-kretschmer.de
обсуждение исходный текст
Ответ на How to convert postgres timestamp to date: yyyy-mm-dd  (CaseT <ctorres@quantumcomposers.com>)
Ответы Re: How to convert postgres timestamp to date: yyyy-mm-dd  (Vivek Khera <vivek@khera.org>)
Re: How to convert postgres timestamp to date: yyyy-mm-dd  (Thomas Kellerer <spam_eater@gmx.net>)
Список pgsql-general
am  Tue, dem 11.03.2008, um 10:51:21 -0700 mailte CaseT folgendes:
> Hi All,
>
> I'm a novice but learning quickly and I'm stumped on how to do this.
>
> I need to convert postgres timestamp to date format yyyy-mm-dd in a
> sql statement.
> pt.created_date below is timestamp format
>
> i.e ... WHERE pt.created_date >=  '2008-01-21'

You can't compare a date or timestamp to a varchar or text. For your
example, cast the date-string to a real date like:

  ... WHERE pt.created_date >=  '2008-01-21'::date


Consider also functions like to_date(), see:
http://www.postgresql.org/docs/current/static/functions-formatting.html


Andreas
--
Andreas Kretschmer
Kontakt:  Heynitz: 035242/47150,   D1: 0160/7141639 (mehr: -> Header)
GnuPG-ID:   0x3FFF606C, privat 0x7F4584DA   http://wwwkeys.de.pgp.net

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

Предыдущее
От: "Kynn Jones"
Дата:
Сообщение: Re: Trigger to run @ connection time?
Следующее
От: "Scott Marlowe"
Дата:
Сообщение: Re: postgre vs MySQL