Re: data type troubles - Mailing list pgsql-general

From Scott Marlowe
Subject Re: data type troubles
Date
Msg-id CAOR=d=2_DyOsFg-8puEA8Ribv7i2-M6Z1xWpxfqPQ0WNB5cBxg@mail.gmail.com
Whole thread Raw
In response to data type troubles  (Kirk Wythers <wythe001@umn.edu>)
List pgsql-general
On Mon, Dec 17, 2012 at 2:38 PM, Kirk Wythers <wythe001@umn.edu> wrote:
>
> I seem to be dealing with a data type issue when I try and import data
> into a new and empty database.
>
> Error Message: ERROR:  date/time field value out of range:
> "1332471600:00:00"
> LINE 1: ...tc_avg25") values ('2012-03-22 21:00:00_B4WARM_A','133247160…
>
> Here are the first two rows in the files I was sent. I cast ROWID as
> varchar32, TIME2 as time (I was told that TIME2 was a posix time value), and
> TIMESTAMP as timestamp.
>
> Any advice that would help me out of this hole is appreciated.

Giant lines deleted.  OK, it looks like the 1332471600 is a unix
timestamp, not a SQL timestamp.

First thing I'd do is make a staging table to hold all these rows.
Declare that second field as bigint and so on, so you can load all
your rows at once.

After all the rows are loaded into a staging table, then you can start
using various pg functions to convert from unix timestamp to sql
timestamp etc.

http://www.postgresql.org/docs/8.4/static/functions-datetime.html

Search for the keyword "epoch" on that page for how to convert back
and forth from unix timestamps.


pgsql-general by date:

Previous
From: Scott Marlowe
Date:
Subject: Re: server registration problems
Next
From: Scott Marlowe
Date:
Subject: Re: Implicit transaction not rolling back after error