Working with dates in Tableau is essential for trend analysis, time-series visualizations, and dynamic dashboards. Tableau provides a rich set of date functions that help you parse, manipulate, and calculate date values with ease.
In this guide, we’ll cover the most commonly used Tableau date functions using the Superstore dataset, along with practical examples and syntax.
1. TODAY()
Returns the current date based on your system clock.
Example:
TODAY()
Use case: Add a calculated field to highlight orders placed today.
2. NOW()
Returns the current date and time.
Example:
NOW()
Use case: Useful when you need both date and time stamps, such as tracking refresh times.
3. DATEPART()
Returns a part (year, month, day, etc.) of a date as an integer.
Syntax:
DATEPART('part', [Date])
Example:
DATEPART('month', [Order Date])
Returns: 1 (for January), 2 (for February), etc.
Use case: Create a filter to show only Q1 orders:
DATEPART('quarter', [Order Date]) = 1
4. DATENAME()
Returns a part of the date as a string (e.g., “January”, “Monday”).
Syntax:
DATENAME('part', [Date])
Example:
DATENAME('month', [Order Date])
Returns: “January”, “February”, etc.
Use case: Create a user-friendly label for tooltips.
5. YEAR(), MONTH(), DAY()
Shortcut functions to extract parts of a date.
Examples:
YEAR([Order Date]) → 2022
MONTH([Order Date]) → 3
DAY([Order Date]) → 15
Use case: Build time-based hierarchies or sort data chronologically.
6. DATEDIFF()
Returns the difference between two dates in specified units.
Syntax:
DATEDIFF('part', [Start Date], [End Date])
Example:
DATEDIFF('day', [Order Date], [Ship Date])
Use case: Calculate shipping delays.
7. DATEADD()
Adds a specific interval to a date.
Syntax:
DATEADD('part', number, [Date])
Example:
DATEADD('month', 3, [Order Date])
Use case: Forecast future dates or create custom fiscal quarters.
8. DATETRUNC()
Truncates a date to the first day of the specified date part.
Syntax:
DATETRUNC('part', [Date])
Example:
DATETRUNC('month', [Order Date])
Returns: The first day of the month for each order.
Use case: Group sales by month without showing individual dates.
9. MAKEDATE() and MAKEDATETIME()
Creates a date or datetime from numeric or string components.
Examples:
MAKEDATE(2023, 6, 19)
MAKEDATETIME([Order Date], #12:00:00#)
Use case: Construct dates from separate year, month, and day fields.
10. ISDATE()
Checks if a string is a valid date.
Example:
ISDATE("2025-01-01") → TRUE
ISDATE("Hello") → FALSE
Use case: Validate user input or data cleaning steps.
11. DATE() and STR()
DATE()
converts a string or number to a date.STR()
converts a date to a string.
Examples:
DATE("2025-06-19") → #June 19, 2025#
STR([Order Date]) → "06/19/2025"
Use case: Convert formats when combining text and date values.
Example Use Case: Creating a Dynamic Year Filter
Let’s say you want to filter sales for the last 2 years dynamically. You could create a calculated field:
YEAR([Order Date]) >= YEAR(TODAY()) - 1
Add this as a filter to always keep your dashboard current without manual changes.
Pro Tip: Fiscal Dates
To create a Fiscal Year starting in July:
IF MONTH([Order Date]) >= 7 THEN YEAR([Order Date]) + 1
ELSE YEAR([Order Date])
END
You can also combine this with DATETRUNC
or DATEPART
to build fiscal quarter logic.
Conclusion
Mastering Tableau date functions helps you build cleaner, smarter dashboards and perform advanced date calculations. Whether you’re comparing year-over-year sales, building time filters, or forecasting future trends, these functions give you the flexibility to handle any time-based analysis.
Discover more from Daily BI Talks
Subscribe to get the latest posts sent to your email.