Thread: conversion from epoch

conversion from epoch

From
"Little, Douglas"
Date:

I have an input source that is in epoch time.    Is there a built-in conversion to changing to timestamp

 

Thanks

 

 

Doug Little

 

Sr. Data Warehouse Architect | Business Intelligence Architecture | Orbitz Worldwide

500 W. Madison, Suite 1000  Chicago IL 60661| Office 312.260.2588 | Fax 312.894.5164 | Cell 847-997-5741

Douglas.Little@orbitz.com

 Description: cid:image001.jpg@01CABEC8.D4980670  orbitz.com | ebookers.com | hotelclub.com | cheaptickets.com | ratestogo.com | asiahotels.com

 

Attachment

Re: conversion from epoch

From
Andreas Kretschmer
Date:



"Little, Douglas" <DOUGLAS.LITTLE@orbitz.com> hat am 30. Juli 2012 um 16:36
geschrieben:


> I have an input source that is in epoch time.    Is there a built-in
> conversion to changing to timestamp
>
>
>
select 'epoch'::date + <your epoch-value> * '1second'::interval;




Andreas

Re: conversion from epoch

From
Steve Atkins
Date:
On Jul 30, 2012, at 7:36 AM, Little, Douglas wrote:

> I have an input source that is in epoch time.    Is there a built-in conversion to changing to timestamp

to_timestamp().

You can also do things like "select timestamptz 'epoch' + ? * interval '1 second'".

Cheers,
  Steve


Re: conversion from epoch

From
Adrian Klaver
Date:
On 07/30/2012 07:36 AM, Little, Douglas wrote:
> I have an input source that is in epoch time.    Is there a built-in
> conversion to changing to timestamp

http://www.postgresql.org/docs/9.1/interactive/functions-formatting.html
"
to_timestamp(double precision)    timestamp with time zone    convert Unix
epoch to time stamp    to_timestamp(1284352323)
"

So:

test=> SELECT to_timestamp(extract(epoch from now()));
          to_timestamp
-------------------------------
  2012-07-30 15:51:42.587106-07


>
> Thanks
>
> *Doug Little*
>


--
Adrian Klaver
adrian.klaver@gmail.com