Datetrunc, Datepart, Datename

by Gordon Hack

When we drag a date field into the view in Tableau, it automatically gets transformed into one of three functions:


We can see these underlying functions if we double click on the date field:

Which function the field turns into determines the form of the field of view, influencing the number of columns or rows and the number of marks drawn. This depends on the type of date formula used and whether it is discrete or continuous.

DATEPART and DATENAME are discrete and respectively return an integer or a string from the specified date, at the specified level of accuracy (‘day’, ‘week’, ‘month’, ‘year’ etc.). DATETRUNC is continuous and truncates the date to the level of accuracy specified.

We can choose exactly how the date gets displayed, and which function is used, by right click and dragging a date onto the view.

The image below gives a summary of the three types of date function by first constructing the calculation and using the ‘month’ level of accuracy.

(Right click and open in new tab to see full resolution!)