Re: Convert from unixtime? - Mailing list pgsql-novice

From Bruno Wolff III
Subject Re: Convert from unixtime?
Date
Msg-id 20030322160200.GA14964@wolff.to
Whole thread Raw
In response to Convert from unixtime?  (Forjan Tamas <tamas@2fkft.com>)
Responses Re: Convert from unixtime?  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-novice
On Wed, Mar 19, 2003 at 20:07:14 +0100,
  Forjan Tamas <tamas@2fkft.com> wrote:
> Greetings.
>
> I have some data files that I need to put into a database. My problem is
> that all date fields are in unix time format (seconds since 1970.01.01
> 0:00). What I would like to find is a function that could be used in
> INSERT commands to convert such data into a date format understandable to
> Postgres. Any ideas?

You can do something like this (in 7.3):

select 1::abstime::timestamp with time zone;
or
select 1::abstime::timestamp with time zone at time zone 'GMT'::timestamp;

Depending on whether or not you want a time zone associated with the
timestamp. Note that if you go directly from abstime to timestamp
(without time zone), then the time will be off by your offset from GMT.


pgsql-novice by date:

Previous
From: brew@theMode.com
Date:
Subject: Re: Problems when deleting data.
Next
From: Tom Lane
Date:
Subject: Re: [GENERAL] Just to ascertain why my posts are going astray