If you’re working in Tableau and using ‘live’ connections to SQL databases then you may have come across an issue where dates/times coming from SQL Server are appearing as NULL in Tableau. I’ve pulled some resources together for hopefully a quick fix:
- Tableau Knowledge base Post: this post walks through reasons why your dates may be NULL and some options for using DATEPARSE along with an 'Extract' connection (rather than a live connection) to fix the issue.
- The official ‘answer’ for this issue: The date/time field from the live data source is of type string. When using a live connection, Tableau Desktop relies on the remote database to perform the conversion from string to date or datetime. Because most databases do not handle these conversions uniformly, Tableau Desktop is unable to enforce a standard behavior.
- Microsoft DATETIME2 Post:
- ICU User Guide Post: in my case, I particularly had an issue with a live connection to a SQL database using this date type. These posts discuss the possible syntax you can use to describe the date in the Tableau DATEPARSE function you need to create
- Tableau DATEPARSE Example:
- My SQL Server date field was in this format: 2016-08-30 15:00:00.0000000
- Here’s the Tableau DATEPARSE function I was able to create to successfully interpret the date: DATEPARSE (“yyyy-MM-dd hh:mm:ss.0000000”, STR([DATETIME2_FIELD]))