Input timestamp from epoch?

Started by Bill Moseleyover 20 years ago2 messagesgeneral
Jump to latest
#1Bill Moseley
moseley@hank.org

I'm entering data into a Postgresql database where the input dates are
currently in unix epoch values. Is there a way for Postgresql to
parse that epoch into a "timestamp(0) with time zone"?

I read section 8.5 "Date/Time Types" and I can see I can input an
(well THE) epoch, and I can EXTRACT(EPOCH FROM [timestamp]), but I'm
not seeing where I can use an epoch format as input for a timestamp(0)
with time zone.

I'm not convinced that I want to store the value as a timestamp. My
time values are all within the epoch range, so that's not an issue.
Then represent a point in time (and event), and I need to display them
in various timezones (depending on where the event is happening).
And the epoch is reasonably easy to work with. I guess a timestamp(0)
with time zone is basically the same thing -- but gives me date
operations on Postgresql. Probably faster for my client application
to parse epoch from the database, though.

--
Bill Moseley
moseley@hank.org

#2A. Kretschmer
akretschmer@despammed.com
In reply to: Bill Moseley (#1)
Re: Input timestamp from epoch?

am 19.08.2005, um 0:27:40 -0700 mailte Bill Moseley folgendes:

I'm entering data into a Postgresql database where the input dates are
currently in unix epoch values. Is there a way for Postgresql to
parse that epoch into a "timestamp(0) with time zone"?

SELECT TIMESTAMP WITH TIME ZONE 'epoch' + 1124438230 * INTERVAL '1 second';
^^^^^^^^^^
your epoch

Regards, Andreas
--
Andreas Kretschmer (Kontakt: siehe Header)
Heynitz: 035242/47212, D1: 0160/7141639
GnuPG-ID 0x3FFF606C http://wwwkeys.de.pgp.net
=== Schollglas Unternehmensgruppe ===