Re: [GENERAL] Extracting time from timestamp - Mailing list pgsql-hackers

From Christopher Kings-Lynne
Subject Re: [GENERAL] Extracting time from timestamp
Date
Msg-id 0a2101c2ef76$25a53a80$6500a8c0@fhp.internal
Whole thread Raw
In response to Fwd: Re: [GENERAL] Extracting time from timestamp  ("Shridhar Daithankar<shridhar_daithankar@persistent.co.in>" <shridhar_daithankar@persistent.co.in>)
List 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 by date:

Previous
From: "Shridhar Daithankar"
Date:
Subject: Fwd: Re: [GENERAL] Extracting time from timestamp
Next
From: Tom Lane
Date:
Subject: Re: Fwd: Re: [GENERAL] Extracting time from timestamp