KNOWLEDGE BASE

Error: [Treasure Data][Presto] (1060) Presto Query Error: Value Cannot Be Cast To Date: Yyyy/mm/dd (9)


Published: 06 Apr 2020
Last Modified Date: 06 Apr 2020

Issue

When creating an extract or using a data/datetime field in a view with Treasure Data (Presto) data source, the following error occurs:
Error: [Treasure Data][Presto] (1060) Presto Query Error: Value cannot be cast to date: yyyy/mm/dd (9)

Environment

  • Tableau Desktop
  • Treasure Data (Presto)

Resolution

When [field] is Date type, change it to String type in Tableau Desktop and use the calculation like this to create Date/Datetime field.

Example 1:
DATE([field])

Example 2:
IF CONTAINS([field],'-') THEN MAKEDATE(INT(SPLIT([field],'-',1)),INT(SPLIT([field],'-',2)),INT(SPLIT([field],'-',3)))
ELSEIF CONTAINS([field],'/') THEN MAKEDATE(INT(SPLIT([field],'/',1)),INT(SPLIT([field],'/',2)),INT(SPLIT([field],'/',3)))
END

*The calculation above may not be supported if you use ODBC driver. Use extract instead or connect with Presto connector to avoid it.

Cause

SQL cast(substring(datetime,1,10)as date) not working properly
Did this article resolve the issue?