Обсуждение: Datetime as a time_t?
Hello, Does anyone know how to extract a datetime field as a time_t? My understanding is that PostgreSQL stores dates internally as a time_t, but I have not figured out how to extract them in that format. I have looked at the casting, and the set datestyles so far. Any ideas? Thanks, -Ryan P.S. I am using PostgreSQL 6.5.3
I have done the following to return a datetime field in unix form:
select datepart('epoch', datetime) from table;
Michael Fork - CCNA - MCP - A+
Network Support - Toledo Internet Access - Toledo Ohio
On Thu, 6 Apr 2000, Ryan Bradetich wrote:
> Hello,
>
> Does anyone know how to extract a datetime field as a time_t?
> My understanding is that PostgreSQL stores dates internally
> as a time_t, but I have not figured out how to extract them in
> that format.
>
> I have looked at the casting, and the set datestyles so far.
> Any ideas?
>
> Thanks,
>
> -Ryan
>
> P.S. I am using PostgreSQL 6.5.3
>
>
Ryan Bradetich <ryan_bradetich@hp.com> writes:
> Does anyone know how to extract a datetime field as a time_t?
date_part('epoch', ...);
Not exactly the first thing you'd think to try, but it works.
regards, tom lane
At 10:27 AM 4/06/00 -0600, Ryan Bradetich wrote: >Does anyone know how to extract a datetime field as a time_t? >My understanding is that PostgreSQL stores dates internally >as a time_t, but I have not figured out how to extract them in >that format. abstime(datetime_field)::int8 works for both datetime and timestamp fields. Frank