Week 4 was a rollercoaster of Tableau, covering everything from the data model to teaching. One of the topics touched on was date functions and their uses. We covered several of the date functions and in this blog I will attempt to clear up how they work and what they do for everyone interested.
Date()
When to use; you want a 'normal' date format, but have unfortunately been given a string/number/some other date format that just isn't working for you. Alternatively, you want a date that means something, like a deadline. This allows you to create this date and add it to a parameter or filter.
How to use; Date('the date format you have') and hopefully that converts it to a regular date format.
Dateparse()
When to use; you want a date format of your choosing, but have been given a string.
How to use; Dateparse('format you want', 'format you have')
Makedate()
When to use; if you want to make a completely arbitrary date.
How to use; Makedate(year,month,day)
Now()
When to use; when you want the current date and time in a datetime format
How to use; Now()
Today()
When to use; when you want the current date only in a date format
How to use; Today()
Datetrunc()
When to use; when you want to truncate the date you have to a certain level (e.g. quarter, month, year, etc.).
How to use; Datetrunc('level of date you want to truncate to', [field to be truncated])