Re: [GENERAL] Extracting time from timestamp

From: "Christopher Kings-Lynne" <chriskl(at)familyhealth(dot)com(dot)au>
To: <shridhar_daithankar(at)persistent(dot)co(dot)in>
Cc: <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [GENERAL] Extracting time from timestamp
Date: 2003-03-21 06:50:23
Message-ID: 0a2101c2ef76$25a53a80$6500a8c0@fhp.internal
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2003-03-21 06:55:16 Re: Fwd: Re: [GENERAL] Extracting time from timestamp
Previous Message Shridhar Daithankar<shridhar_daithankar@persistent.co.in> 2003-03-21 06:45:13 Fwd: Re: [GENERAL] Extracting time from timestamp