KNOWLEDGE BASE

Date format changes upon converting Date&Time to String


Published: 03 Jul 2020
Last Modified Date: 03 Jul 2020

Issue

Date format changes from e.g. [2020-12-01 06:12:49] to [Dec 1 2020 6:12:49] when you convert the data type of a field from Date&Time to String. This occurs when using the live data source connection to Oracle or SQL Server.
 

Environment

  • Tableau Desktop 
  • Oracle, SQL Server

Resolution

Make a Calculation Filed to change the data format which matches  [2020-12-01 06:12:49] as a String.

STR(YEAR([Date]))+ "-"
+ (IF MONTH([Date])<10 THEN "0"+STR(MONTH([Date])) ELSE STR(MONTH([Date])) END) + "-"
+(IF DAY([Date])<10 THEN "0"+STR(DAY([Date])) ELSE STR(DAY([Date])) END)+ " "
+RIGHT(STR([Date]),8)
 

Cause

Within a Live connection with some data bases(Oracle, SQL Server), When change data type from Date(Date&Time) to String,
the Query from Tableau to database will be automatically issued which changes the format of String in query.

Additional Information


 
Did this article resolve the issue?