Re: Question about copy from with timestamp format - Mailing list pgsql-general

From Adrian Klaver
Subject Re: Question about copy from with timestamp format
Date
Msg-id 55B95886.7000107@aklaver.com
Whole thread Raw
In response to Question about copy from with timestamp format  (Murali M <manips2002@gmail.com>)
Responses Re: Question about copy from with timestamp format
List pgsql-general
On 07/29/2015 03:42 PM, Murali M wrote:
> Hi,
>
> I wanted to copy a file from local file system to postgres. I have
> timestamp value specified as:
> YYYYMMDDHH24 format -- for example:
> 2015072913 -- is July 29, 2015 at 13:00
>
> how do I import this data into a timestamp field?
>
> thanks, murali.
>
> PS: I believe if I need the hour, I need to use timestamp (I do not want
> to put the hour as a separate column). I believe date datatype does not
> work, if I am right??

test=# create table ts_test(ts_fld timestamp);
CREATE TABLE

test=# insert into ts_test values (to_timestamp('2015072913',
'YYYYMMDDHH24'));
INSERT 0 1

test=# select * from ts_test ;
        ts_fld
---------------------
  2015-07-29 13:00:00
(1 row)

For more information:

http://www.postgresql.org/docs/9.4/interactive/functions-formatting.html

--
Adrian Klaver
adrian.klaver@aklaver.com


pgsql-general by date:

Previous
From: Murali M
Date:
Subject: Question about copy from with timestamp format
Next
From: Murali M
Date:
Subject: Re: Question about copy from with timestamp format