Conversion from Unix timestamp to datetime? - Mailing list pgsql-sql

From Tom Lane
Subject Conversion from Unix timestamp to datetime?
Date
Msg-id 10692.900357707@sss.pgh.pa.us
Whole thread Raw
Responses How do I store graphics in my tables?  (Dan Delaney <dionysos@dionysia.org>)
List pgsql-sql
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

pgsql-sql by date:

Previous
From: Guido Piazzi
Date:
Subject: Re: [SQL] empty data
Next
From: Dan Delaney
Date:
Subject: How do I store graphics in my tables?