Re: [GENERAL] Extracting time from timestamp

Поиск
Список
Период
Сортировка
От Christopher Kings-Lynne
Тема Re: [GENERAL] Extracting time from timestamp
Дата
Msg-id 0a2101c2ef76$25a53a80$6500a8c0@fhp.internal
обсуждение исходный текст
Ответ на Fwd: Re: [GENERAL] Extracting time from timestamp  ("Shridhar Daithankar<shridhar_daithankar@persistent.co.in>" <shridhar_daithankar@persistent.co.in>)
Список pgsql-hackers
> > select "time"(abstime(timestamp 'now')) from bookings;
> > select "time"(timestamp 'now') from bookings;
>
> First of all, thanks, it worked..
>
> And What's so holy about "" if it is a function?

It's really old 7.1 syntax, not supported from 7.2+.

Basically it's because time can now have a precision.  eg. a field of type
TIME(4) will have decimal places of millisecond precision.  You need to
quote the function to make it get treated as a function rather than a type
definition...

A better (standard) way to express it is probably:

select cast(cast(current_timestamp as abstime) as time) from bookings;

or even

select current_timestamp::abstime::time from bookings;

Chris



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

Предыдущее
От: "Shridhar Daithankar"
Дата:
Сообщение: Fwd: Re: [GENERAL] Extracting time from timestamp
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Fwd: Re: [GENERAL] Extracting time from timestamp