3

Im using postgres 10.1 and the Datestyle config is the following

 DateStyle
 -----------
 ISO, MDY

Im having this error

ERROR: date/time field value out of range: "1535673858" Hint: Perhaps you need a different "datestyle" setting.

While executing the following insert statement:

INSERT INTO ex (taken_ats) VALUES('{ 1535673858 , 1535678856}')

Schema:

CREATE TABLE ex (
    taken_ats TIMESTAMP WITHOUT TIME ZONE[]
)
1
  • 1535673858 is not a "timestamp" - that's a number
    – user1822
    Commented Aug 31, 2018 at 6:54

1 Answer 1

3

1535673858 is neither in the ISO format, nor in any of the other valid date input formats.

To convert a Unix epoch value into the internal Postgres type, you must use the single-argument to_timestamp() function:

INSERT INTO ex(taken_ats) VALUES(ARRAY[to_timestamp(1535673858), to_timestamp(1535678856)]);

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.