0

I'm having problems when changing the date format for the datepicker. I want to have the 'dd/mm/yyyy/ date format but postgres throws me this error:

ActiveRecord::StatementInvalid - PG::DatetimeFieldOverflow: ERROR:  date/time field value out of range: "16/07/2014"
Perhaps you need a different "datestyle" setting.

because of its american way of saving the date format.

2 Answers 2

4

Set datestyle in your postgreSQL database as below:

SET datestyle = "ISO, DMY";
Sign up to request clarification or add additional context in comments.

2 Comments

I edited the postgresql.conf file line "datestyle = 'iso, mdy' to 'iso, dmy' but I get the same result..
Have you restart postgreSQL after changing the file?
4

The datestyle setting defines a default for your system. Consider @Ilesh's answer. The setting in postgresql.conf applies to all databases in the db cluster.

To make statements work without regard to the setting, use the to_date() function to form date values from string constants:

SELECT to_date('16/07/2014', 'DD/MM/YYYY');

Related:
Store date with optional month / day

Comments

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.