Re: SELECT 'NOW()' - OK, SELECT 'CLOCK_TIMESTAMP()' - ERROR

Поиск
Список
Период
Сортировка
От Ian Barwick
Тема Re: SELECT 'NOW()' - OK, SELECT 'CLOCK_TIMESTAMP()' - ERROR
Дата
Msg-id 53F6EA7A.2030408@2ndquadrant.com
обсуждение исходный текст
Ответ на SELECT 'NOW()' - OK, SELECT 'CLOCK_TIMESTAMP()' - ERROR  (Piotr Gasidło <quaker@barbara.eu.org>)
Список pgsql-general
On 14/08/22 15:40, Piotr Gasidło wrote:
> Hello,
>
> I found strange PostgreSQL 9.3 behavior:
>
>> select now()::timestamp, 'now()'::timestamp;
>             now             |         timestamp
> ----------------------------+----------------------------
>  2014-08-22 08:34:00.883268 | 2014-08-22 08:34:00.883268
>
> Second column is now() in single apostrophes.
>
> Now, I tried similar function, clock_timestamp() and get:
>
>> select clock_timestamp()::timestamp, 'clock_timestamp()'::timestamp;
> ERROR:  invalid input syntax for type timestamp: "clock_timestamp()"
> LINE 1: select clock_timestamp()::timestamp, 'clock_timestamp()'::ti...
>                                                ^
>
> Why is NOW() so special? Where is it documented?

Here:
  http://www.postgresql.org/docs/current/interactive/functions-datetime.html#FUNCTIONS-DATETIME-CURRENT

  "All the date/time data types also accept the special literal value 'now' to
   specify the current date and time"

and also here:

  http://www.postgresql.org/docs/9.3/static/datatype-datetime.html#AEN5861

Regards


Ian Barwick


--
 Ian Barwick                   http://www.2ndQuadrant.com/
 PostgreSQL Development, 24x7 Support, Training & Services


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

Предыдущее
От: Piotr Gasidło
Дата:
Сообщение: SELECT 'NOW()' - OK, SELECT 'CLOCK_TIMESTAMP()' - ERROR
Следующее
От: David G Johnston
Дата:
Сообщение: Re: SELECT 'NOW()' - OK, SELECT 'CLOCK_TIMESTAMP()' - ERROR