Re: data type - import problem - Mailing list pgsql-general

From Adrian Klaver
Subject Re: data type - import problem
Date
Msg-id 50CF9720.5050508@gmail.com
Whole thread Raw
In response to data type - import problem  (Kirk Wythers <kirk.wythers@gmail.com>)
Responses Re: data type - import problem  (Kirk Wythers <kirk.wythers@gmail.com>)
List pgsql-general
On 12/17/2012 01:53 PM, Kirk Wythers 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.

Assuming by POSIX time you mean seconds since epoch you will need to do
something like this:

test=# SELECT to_timestamp(1332471600);
       to_timestamp
------------------------
  2012-03-22 20:00:00-07

For time:
test=# SELECT to_timestamp('1332471600')::time;
  to_timestamp
--------------
  20:00:00


In your INSERT statement use the to_timestamp() in the VALUES portion.
--
Adrian Klaver
adrian.klaver@gmail.com


pgsql-general by date:

Previous
From: Guillaume Lelarge
Date:
Subject: Re: XML Schema for PostgreSQL database
Next
From: Thomas Kellerer
Date:
Subject: Re: XML Schema for PostgreSQL database