6

I have a pipe delimited file that I'm importing into Postgres (9.2.8) using the command:

COPY schema.tablename FROM '/path/to/file.csv' DELIMITERS '|' CSV

It has been working reliably for a while, but just choked on:

Query failed: ERROR: invalid input syntax for type timestamp: "Sep 24 2013 12:00:00:000AM"

That looks like a valid timestamp to me. Any suggestions?

1 Answer 1

9

It's the last :000 that's messing you up. For whatever reason, the timestamp-formatting gods decreed that milleseconds be delimited with a "." instead of a ":".

jberkus=# select timestamp 'Sep 24 2013 12:00:00:000AM';

ERROR:  invalid input syntax for type timestamp: "Sep 24 2013 12:00:00:000AM"

jberkus=# select timestamp 'Sep 24 2013 12:00:00.000AM';

          timestamp      
    ---------------------
    2013-09-24 00:00:00
    (1 row)
Sign up to request clarification or add additional context in comments.

1 Comment

Thank you! I can't change the 3rd party data, but I can at least scrub / fix it beforehand so it doesn't choke.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.