Open In App

Date functions in Tableau

Tableau has calculated fields which helps us apply logical or arithmetic operations for any field present in the data source

Most of the data sources use time references in it. Hence, they contain one or more date values in them. The date functions play a major role here. As the name says, these are used to perform operations on fields of data type date or date time. They are also used to create a date field or check whether it is the one. There are multiple date functions in Tableau and are used for multiple purposes. Let us see them in detail.



You can also get to see all the date functions and their basic definition from the tableau calculated field itself.
– Click on the small downward arrow as in the below pic.

Select ‘Create calculated field’ from the list
A calculated field will get opened as shown in the below pic and then click on rightward arrow over there on the right side of that calculated field.
Then, a section with all the functions will get opened as in the below pic. Either click on the downward arrow beside All and choose Date from there or click on the search bar and enter date over there.
In either ways, you will be able to see all the date functions and their basic definitions.

Before moving into the date functions, it is important to know all the date parts available in Tableau and their values.



Date Parts

Date Functions

This function is used to either convert a datetime field into date data type or convert anything in general as a date. Make sure to use quotes in order to give any specific date.

Dateadd

This function is used to add or subtract certain period from any specific date. Mention the date part where you want it to be effected, interval of how much period you want to increment or decrement and date in their respective positions. The output here will be a datetime data type.

Datediff

This function shows the difference between start date and end date specified.( start date is subtracted from the end date). It subtracts the specific date part mentioned and provides the output. Start of week is where you have to specify the starting week day( be it Sunday, Monday or any week day) and this is optional. If nothing is specified, it takes the value according to the data source used.)

Datename

This function provides the name of the specific date part mentioned. It is useful in case of months as it provides the complete name of the month. For other date parts, it acts similar to the datepart function.

Dateparse

This function is used to to convert any given string or string field to date time format. But you have to be sure of which format that field is in and you have to specify it exactly for it to work fine.

Datepart

This function returns any specified part of the date mentioned or date field provided. Again, start of week is optional. It would consider it according to the default data source if not provided any.

Datetime

This function gives output as datetime even if we enter a number, string or date expression inside the quotation marks.

Datetrunc

This function truncates the date part in the specified date i.e it gives the starting date based on the date part mentioned. Start of week is optional. If not mentioned any, it assigns according to the default data source.

Isdate

Makedate

Makedatetime

This function returns date time as out put based on the date and time mentioned inside hashtags.


Article Tags :