From: Richard Huxton <dev@archonet.com>
To: Roberto Mello <rmello@cc.usu.edu>
To: pgsql-sql@postgresql.org
Subject: Re: Converting epoch to timestamp?
Date: Wed, 1 Aug 2001 09:28:39 +0100
Message-ID: <001b01c11a63$f86779e0$1001a8c0@archonet.com> (raw)
References: <20010801005708.A16786@cc.usu.edu>
From: "Roberto Mello" <rmello@cc.usu.edu>
Hi Roberto - long time no see.
> I searched the docs for function to convert epoch to timestamps but
> couldn't find any. Are there any?
richardh=> select now();
now
------------------------
2001-08-01 09:25:58+01
(1 row)
richardh=> select extract('epoch' from now());
date_part
-----------
996654359
(1 row)
richardh=> select '1970-01-01'::date + '996654342 seconds'::interval;
?column?
------------------------
2001-08-01 08:25:42+01
(1 row)
That's the only way I've ever known to do it. Note the one-hour offset
because I'm currently in BST rather than GMT timezone (ignore the few
seconds discrepancy - that's me querying then cutting and pasting).
Be interested to find out if there's a neater way. Can't believe there's not
some EPOCH_BASE constant that could be used.
- Richard Huxton
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 using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: dev@archonet.com, rmello@cc.usu.edu
Subject: Re: Converting epoch to timestamp?
In-Reply-To: <001b01c11a63$f86779e0$1001a8c0@archonet.com>
* 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