KNOWLEDGE BASE

STR() Function Ignores the Default Date and Number Formatting


Published: 12 Jun 2013
Last Modified Date: 24 Jul 2017

Issue

When you wrap date or number fields in the STR() function in calculated fields, the default number and date formatting might not be respected.

For example, if you set the default format for a date field (Default Properties > Date Format) to display only hours and minutes and then use the same field in a calculation and wrapped in the STR() function, the resulting date will display hours, minutes, and seconds.

Environment

Tableau Desktop

Resolution

Use string functions to control date and number formatting in calculated fields. For example, the formula below will display only the leftmost four characters in the date string.
LEFT(STR([Order Date]),4)

Additional Information

Did this article resolve the issue?