Received: from finch-post-12.mail.demon.net (finch-post-12.mail.demon.net [194.217.242.41]) by postgresql.org (8.11.3/8.11.1) with ESMTP id f718XNf81413 for ; Wed, 1 Aug 2001 04:33:24 -0400 (EDT) (envelope-from dev@archonet.com) Received: from mwynhau.demon.co.uk ([193.237.186.96] helo=mainbox.archonet.com) by finch-post-12.mail.demon.net with esmtp (Exim 2.12 #1) id 15RrRQ-000O1R-0C; Wed, 1 Aug 2001 08:33:20 +0000 Received: from client (client.archonet.com [192.168.1.16]) by mainbox.archonet.com (Postfix) with SMTP id A702D1488A; Wed, 1 Aug 2001 09:28:42 +0100 (BST) Message-ID: <001b01c11a63$f86779e0$1001a8c0@archonet.com> From: "Richard Huxton" To: "Roberto Mello" , References: <20010801005708.A16786@cc.usu.edu> Subject: Re: Converting epoch to timestamp? Date: Wed, 1 Aug 2001 09:28:39 +0100 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 5.50.4133.2400 X-MIMEOLE: Produced By Microsoft MimeOLE V5.50.4133.2400 X-Archive-Number: 200108/2 X-Sequence-Number: 4223 From: "Roberto Mello" 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