Re: data type troubles

From: Scott Marlowe <scott(dot)marlowe(at)gmail(dot)com>
To: Kirk Wythers <wythe001(at)umn(dot)edu>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: data type troubles
Date: 2012-12-22 05:28:20
Message-ID: CAOR=d=2_DyOsFg-8puEA8Ribv7i2-M6Z1xWpxfqPQ0WNB5cBxg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Mon, Dec 17, 2012 at 2:38 PM, Kirk Wythers <wythe001(at)umn(dot)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.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Scott Marlowe 2012-12-22 05:32:24 Re: Implicit transaction not rolling back after error
Previous Message Scott Marlowe 2012-12-22 05:21:29 Re: server registration problems