From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-sql@postgresql.org
Subject: Conversion from Unix timestamp to datetime?
Date: Mon, 13 Jul 1998 15:21:47 -0400
Message-ID: <10692.900357707@sss.pgh.pa.us> (raw)
I'd like to be able to convert between times specified in Unix timestamp
format and SQL datetime values without going through the slow and rather
error-prone process of converting to a human-readable date notation.
I see how to get a datetime value returned as a Unix timestamp:
tgl=> select date_part('epoch', 'now'::datetime);
date_part
---------
900355156
(1 row)
But I don't see any way to supply a value in the form "900355156"
and have it get converted to datetime. Is there a way to do that?
BTW, it seems like the standard data type 'timestamp' ought to be
good for this, but it isn't as far as I can tell ... it hasn't got
any working conversions to/from integer either.
regards, tom lane
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-sql@postgresql.org
Cc: tgl@sss.pgh.pa.us
Subject: Re: Conversion from Unix timestamp to datetime?
In-Reply-To: <10692.900357707@sss.pgh.pa.us>
References: <10692.900357707@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
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