Re: Convert from unixtime?

From: Bruno Wolff III <bruno(at)wolff(dot)to>
To: Forjan Tamas <tamas(at)2fkft(dot)com>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: Convert from unixtime?
Date: 2003-03-22 16:02:00
Message-ID: 20030322160200.GA14964@wolff.to
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

On Wed, Mar 19, 2003 at 20:07:14 +0100,
Forjan Tamas <tamas(at)2fkft(dot)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.

In response to

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Tom Lane 2003-03-22 16:08:45 Re: Just to ascertain why my posts are going astray
Previous Message brew 2003-03-22 13:02:52 Re: Problems when deleting data.