Search Postgresql Archives

Re: data type troubles

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Dec 17, 2012 at 2:38 PM, Kirk Wythers <wythe001@xxxxxxx> 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.


-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux