pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedDatetime as a time_t?
4+ messages / 4 participants
[nested] [flat]
* Datetime as a time_t?
@ 2000-04-06 16:27 Ryan Bradetich <ryan_bradetich@hp.com>
2000-04-06 19:46 ` Re: Datetime as a time_t? Michael Fork <mfork@toledolink.com>
2000-04-06 20:54 ` Re: Datetime as a time_t? Tom Lane <tgl@sss.pgh.pa.us>
2000-04-06 21:51 ` Re: Datetime as a time_t? Frank Bax <fbax@execulink.com>
0 siblings, 3 replies; 4+ messages in thread
From: Ryan Bradetich @ 2000-04-06 16:27 UTC (permalink / raw)
To: pgsql-sql
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
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: Datetime as a time_t?
2000-04-06 16:27 Datetime as a time_t? Ryan Bradetich <ryan_bradetich@hp.com>
@ 2000-04-06 19:46 ` Michael Fork <mfork@toledolink.com>
2 siblings, 0 replies; 4+ messages in thread
From: Michael Fork @ 2000-04-06 19:46 UTC (permalink / raw)
To: Ryan Bradetich <ryan_bradetich@hp.com>; +Cc: pgsql-sql
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
>
>
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: Datetime as a time_t?
2000-04-06 16:27 Datetime as a time_t? Ryan Bradetich <ryan_bradetich@hp.com>
@ 2000-04-06 20:54 ` Tom Lane <tgl@sss.pgh.pa.us>
2 siblings, 0 replies; 4+ messages in thread
From: Tom Lane @ 2000-04-06 20:54 UTC (permalink / raw)
To: Ryan Bradetich <ryan_bradetich@hp.com>; +Cc: pgsql-sql
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
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: Datetime as a time_t?
2000-04-06 16:27 Datetime as a time_t? Ryan Bradetich <ryan_bradetich@hp.com>
@ 2000-04-06 21:51 ` Frank Bax <fbax@execulink.com>
2 siblings, 0 replies; 4+ messages in thread
From: Frank Bax @ 2000-04-06 21:51 UTC (permalink / raw)
To: pgsql-sql
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
^ permalink raw reply [nested|flat] 4+ messages in thread
end of thread, other threads:[~2000-04-06 21:51 UTC | newest]
Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2000-04-06 16:27 Datetime as a time_t? Ryan Bradetich <ryan_bradetich@hp.com>
2000-04-06 19:46 ` Michael Fork <mfork@toledolink.com>
2000-04-06 20:54 ` Tom Lane <tgl@sss.pgh.pa.us>
2000-04-06 21:51 ` Frank Bax <fbax@execulink.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox