EducationSoftwareStrategy.com
StrategyCommunity

Knowledge Base

Product

Community

Knowledge Base

TopicsBrowse ArticlesDeveloper Zone

Product

Download SoftwareProduct DocumentationSecurity Hub

Education

Tutorial VideosSolution GalleryEducation courses

Community

GuidelinesGrandmastersEvents
x_social-icon_white.svglinkedin_social-icon_white.svg
Strategy logoCommunity

© Strategy Inc. All Rights Reserved.

LegalTerms of UsePrivacy Policy
  1. Home
  2. Topics

Error “date/time field out of range” occurs for MDY date style


Junjie Shi

Quality Engineer, Senior • MicroStrategy


This article indicates one possible cause for the error “date/time field out of range”, when running query against PostgreSQL database instance.

SYMPTOM:

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"
 

CAUSE:

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.
 

ACTION:

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.
 


Comment

0 comments

Details

Knowledge Article

Published:

June 10, 2022

Last Updated:

June 10, 2022