Parts, Names, and Truncs


There are a little trio of functions that could be very useful for anyone working with dates. These are DateTrunc DatePart and DateName.


These three functions all deal with extracting a particular detail or level of detail from any given date. DateTrunc() is the first of these and looks at removing detail from a particular date, for example using DateTrunc(‘week’ date) will give the start date for the week that the input date falls into, the start of the week is either specified in the formula or in the settings for the data source. DateTrunc is particularly useful for allowing or disallowing users to only go down to a certain level of detail when exploring date related data.


DatePart and DateName both work in similar ways; these allow you to access a particular discrete part of the date and to then use it. DatePart allows you to extract an integer value from the date and date name allows you to extract a string value instead. For example

DATENAME('weekday',#21/11/2016#) will give Monday, while DATEPART('weekday',#21/11/2016#) will give 1 (assuming that Monday is the start of the week). DATENAME and DATEPART are both really useful when thinking about days of the week and performing analysis like which day of the week is most popular and which day is the most profitable.


I hope you have found this article useful follow out twitter feed @cloudstream_uk for more tableau tips, tutorials and news.


Free Alteryx Trial!

Free Tableau Trial!

Get in touch with us today!

Contact us
Cookies make it easier for us to provide you with our services. With the usage of our services you permit us to use cookies.
More information Ok