Error “date/time field value out of range: "12/30/2018"(Hint Perhaps you need a different "datestyle" setting.;” occurs, when the generated SQL contains comparison between two date types where one date type is of MDY date style.
For example, below SQL will trigger the error.
select "a11"."CUSTOMER_ID" AS "CUSTOMER_ID",
max("a12"."CUST_LAST_NAME") AS "CUST_LAST_NAME",
max("a12"."CUST_FIRST_NAME") AS "CUST_FIRST_NAME",
"a11"."ORDER_ID" AS "ORDER_ID",
(max("a11"."ORDER_DATE") + 3.0 * INTERVAL '1 DAY') AS "WJXBFS1",
case (max("a11"."ORDER_DATE") + 3.0 * INTERVAL '1 DAY') when '12/30/2018' then 'YearEnd' when '05/15/2017' then 'YearStart' else 'YearMiddle' end AS "WJXBFS2",
case CAST((max("a11"."ORDER_DATE") + 3.0 * INTERVAL '1 DAY') AS DATE) when '12/30/2018' then 'YearEnd' when '05/15/2017' then 'YearStart' else 'YearMiddle' end AS "WJXBFS3"
from "ORDER_FACT" "a11"
join "LU_CUSTOMER" "a12"
on ("a11"."CUSTOMER_ID" = "a12"."CUSTOMER_ID")
where ("a11"."CUSTOMER_ID" in (564, 1607)
and "a11"."ORDER_ID" < 100000)
group by "a11"."CUSTOMER_ID",
"a11"."ORDER_ID"
Strategy ODBC Driver for PostgreSQL Wire Protocol, and the JDBC driver (mypostgresql.jar) doesn’t support date style MDY. In above example, ‘12/20/2018’ is MDY date style.
Strategy ODBC Driver for PostgreSQL Wire Protocol, and the JDBC driver (mypostgresql.jar) support YMD date style. User could use YMD instead of MDY date style. In above example, change the date, for example, 12/20/2018 to 2018/12/20.