In this post, we’ll be exploring date functions in Tableau. We’ll start off with a cheat sheet, showcasing the more commonly used date functions with examples and outputs. And then diving into five real-world use cases, such as shipping delays, month-over-month sales and average shipping times.

Commonly Used Date Functions

Function Example Output Description
DATE DATE(“2025-07-09 16:36”) 2025-07-09 Converts a string or datetime to a date (removes timestamp).
DATEPART DATEPART(‘month’, #2025-07-09#) 7 Returns specific part of the date as an integer
DATENAME DATENAME(‘month’, #2025-07-09#) July Returns name of date part (e.g. “July” for month).
DATEADD DATEADD(‘month’, 2, #2025-07-09#) 2025-09-09 Adds an interval to a date
DATETRUNC DATETRUNC(‘month’, #2025-07-09#) 2025-07-01 Truncates a date to the specified part (e.g. start of month).
TODAY TODAY() 2025-07-11 Returns the current date
NOW NOW() 2025-07-11 14:52:00 Returns current date and time
YEAR YEAR(#2025-07-09#) 2025 Returns the year part of a date
MONTH MONTH(#2025-07-09#) 7 Returns the month as an integer (1–12).
DAY DAY(#2025-07-09#) 9 Returns the day of the month as an integer.
WEEK WEEK(#2025-07-09#) 28 Returns the week number of the year
ISDATE ISDATE(“2025-07-09”) TRUE Returns TRUE if the value is a valid date.
MAKEDATE MAKEDATE(2025, 7, 9) 2025-07-09 Creates a date from year, month, and day values.
DATETIME DATETIME(“2025-07-09 14:30”) 2025-07-09 14:30:00 Converts a string to a full datetime
DATEDIFF DATEDIFF(‘day’, #2025-07-01#, #2025-07-09#) 8 Returns the number of units (days, months) between two dates

 

Use Cases & Scenarios

Year-on-Year Sales

YEAR([Order Date])

By using the Year function, we extract the Year from a full date as a number. Stripping away month and day, focusing only on year. Which is useful for comparing trends over time, or filter data by a specific year. For this example, we can assess Category sales by year. Helping us see how each category performs annually.

Filter to Sales for this Month Only

 

DATEPART('month', [Order Date]) = DATEPART('month', TODAY())

This calculated field checks whether the month of each order date, matches the current month to today. For this example, today is July 13, so any order that occurred in the month of July, regardless of year, will return true. This is particularly useful when analysing seasonal trends over multiple years to track month-over-month comparisons. DATEPART is highly flexible and can also compare dates by week, quarter, year, or day. For example, quarter:

DATEPART('quarter', [Order Date]) = DATEPART('quarter', TODAY())

 

 

Days Between Order Date and Ship Date

DATEDIFF('day', [Order Date], [Ship Date])

Through the use of the DATEDIFF function, we are able to extract the number of days between the Order Date and Ship Date. We can even take this a step further by flagging any days that take too long to ship.

IF DATEDIFF('day', [Order Date], [Ship Date]) > 6 THEN "Delayed"
ELSE "On Time"
END

This calculation checks if an order exceeded 6 days and will flag if it is delayed. This can be useful to colour code any orders that are delayed or it can even be used as a filter to find delayed orders only.

Average Shipping time by Region

AVG(DATEDIFF('day', [Order Date], [Ship Date]))

This calculation finds the average number of days it takes for an order to ship from the order date. DATEDIFF calculates the number of days between the two date fields and AVG then averages those values across all orders. This can then be compared to different fields such as region, shipping mode, category, cities, to find any insights on any areas that are taking longer to ship than normal.

Total Orders – Weekend vs Weekday

IF DATEPART('weekday', [Order Date]) = 1 OR DATEPART('weekday', [Order Date]) = 7
THEN "Weekend"
ELSE "Weekday"
END

This calculation identifies weekends by checking if the weekday number is equal to 1 (Sunday) or 7 (Saturday). These weekdays are then grouped into “Weekend”, while any other days that do not fall into my category (2-6) are classified as “Weekday”. This method is flexible and can be used highlight specific days based on what days you would like to analyse.

Jack Woodward
Author: Jack Woodward