Date Functions in Tableau
Learn how to work with date and time data in Tableau using built-in date functions. Understand date extraction, date truncation, date differences, date calculations, date formatting and practical time-based business analysis.
1. Introduction to Date Functions
Date Functions in Tableau are used to perform calculations and analysis on date and time fields. They help users extract date components, calculate differences between dates, add or subtract time intervals and group records by specific date levels.
Date functions are important when working with business datasets containing Order Date, Shipping Date, Delivery Date, Joining Date and other time-related information.
Why Are Date Functions Used?
- Extract year, month, quarter and day from a date.
- Calculate the number of days between two dates.
- Add or subtract days, months and years.
- Calculate monthly, quarterly and yearly sales.
- Identify the first and last dates of a reporting period.
- Analyze order processing and delivery time.
- Create date-based filters and calculated fields.
- Support trend analysis and forecasting.
2. Understanding Date and Time Data Types
Before using date functions, it is important to understand the date and time data types supported by Tableau.
| Data Type | Description | Example |
|---|---|---|
| Date | Stores calendar date information. | 2026-11-04 |
| Date & Time | Stores both date and time information. | 2026-11-04 14:30:00 |
| String | Text that may contain date-like values. | November 04, 2026 |
| Integer | Numeric values sometimes used to represent date parts. | 2026 |
Example Dataset
| Order ID | Order Date | Ship Date | Sales |
|---|---|---|---|
| 1001 | 2026-01-05 | 2026-01-08 | 15000 |
| 1002 | 2026-02-10 | 2026-02-14 | 20000 |
| 1003 | 2026-03-15 | 2026-03-18 | 12000 |
| 1004 | 2026-04-20 | 2026-04-25 | 18000 |
In this dataset, Order Date and Ship Date can be used to calculate shipping duration, monthly sales and other date-based business metrics.
3. Important Date Functions in Tableau
Tableau provides several built-in date functions. The following functions are commonly used in reporting and business analysis.
| Function | Purpose |
|---|---|
| DATEPART() | Extracts a specific part of a date as an integer. |
| DATENAME() | Returns the name of a date part as text. |
| DATETRUNC() | Truncates a date to a specified date level. |
| DATEDIFF() | Calculates the difference between two dates. |
| DATEADD() | Adds or subtracts a specified interval from a date. |
| DATE() | Converts an expression into a date value. |
| DATEPARSE() | Converts text into a date using a specified format. |
| MAKEDATE() | Creates a date from year, month and day values. |
| TODAY() | Returns the current date. |
| NOW() | Returns the current date and time. |
| ISDATE() | Checks whether a value can be interpreted as a date. |
4. DATEPART() Function
DATEPART() extracts a specific component of a date and returns it as an integer. It is useful when you need numeric date components for calculations, filtering or comparisons.
Syntax
DATEPART(date_part, date)
Example: Extract Year
DATEPART('year', [Order Date])
Example: Extract Month
DATEPART('month', [Order Date])
Example: Extract Day
DATEPART('day', [Order Date])
Supported Date Parts
| Date Part | Meaning | Example Result |
|---|---|---|
| 'year' | Year | 2026 |
| 'quarter' | Quarter number | 1 |
| 'month' | Month number | 11 |
| 'day' | Day of month | 4 |
| 'week' | Week number | 45 (depending on week settings) |
| 'weekday' | Day of week number | 4 (depending on week settings) |
| 'hour' | Hour | 14 |
| 'minute' | Minute | 30 |
| 'second' | Second | 0 |
Practical Example
Suppose a sales manager wants to analyze sales by year. Create a calculated field named Order Year.
DATEPART('year', [Order Date])
Drag Order Year into the worksheet to group or filter records using the extracted year.
5. DATENAME() Function
DATENAME() returns the name of a specified date component as a string. Unlike DATEPART(), which returns a numeric value, DATENAME() returns text.
Syntax
DATENAME(date_part, date)
Example: Month Name
DATENAME('month', [Order Date])
Example: Weekday Name
DATENAME('weekday', [Order Date])
Example: Quarter Name
DATENAME('quarter', [Order Date])
DATEPART vs DATENAME
| Function | Expression | Result Type | Example |
|---|---|---|---|
| DATEPART | DATEPART('month', [Order Date]) | Integer | 11 |
| DATENAME | DATENAME('month', [Order Date]) | String | November |
6. DATETRUNC() Function
DATETRUNC() truncates a date to a specified date part. It removes the smaller date components while preserving the selected level.
For example, truncating a date to the month level returns the first day of that month. Truncating to the year level returns the first day of that year.
Syntax
DATETRUNC(date_part, date)
Example: Month
DATETRUNC('month', [Order Date])
Example: Year
DATETRUNC('year', [Order Date])
Example: Quarter
DATETRUNC('quarter', [Order Date])
Example Results
| Original Date | Expression | Result |
|---|---|---|
| 2026-11-04 | DATETRUNC('month', date) | 2026-11-01 |
| 2026-11-04 | DATETRUNC('year', date) | 2026-01-01 |
| 2026-11-04 | DATETRUNC('quarter', date) | 2026-10-01 |
Practical Example: Monthly Sales Grouping
DATETRUNC('month', [Order Date])
This calculation groups dates into monthly periods. It is useful when different dates within the same month must be summarized together.
7. DATEDIFF() Function
DATEDIFF() calculates the difference between two dates using a specified date part. It is useful for measuring the time between business events.
Syntax
DATEDIFF(date_part, start_date, end_date)
Example: Difference in Days
DATEDIFF('day', [Order Date], [Ship Date])
Example: Difference in Months
DATEDIFF('month', [Start Date], [End Date])
Example: Difference in Years
DATEDIFF('year', [Joining Date], [Today Date])
Example Dataset
| Order ID | Order Date | Ship Date | Shipping Days |
|---|---|---|---|
| 1001 | 2026-01-05 | 2026-01-08 | 3 |
| 1002 | 2026-02-10 | 2026-02-14 | 4 |
| 1003 | 2026-03-15 | 2026-03-18 | 3 |
| 1004 | 2026-04-20 | 2026-04-25 | 5 |
Calculated Field: Shipping Duration
DATEDIFF('day', [Order Date], [Ship Date])
The expression calculates the difference between Order Date and Ship Date in days.
Common Date Parts Used with DATEDIFF
- 'year' - Difference in year boundaries.
- 'quarter' - Difference in quarter boundaries.
- 'month' - Difference in month boundaries.
- 'week' - Difference in week boundaries.
- 'day' - Difference in day boundaries.
- 'hour' - Difference in hour boundaries.
- 'minute' - Difference in minute boundaries.
- 'second' - Difference in second boundaries.
8. DATEADD() Function
DATEADD() adds or subtracts a specified number of date intervals from an existing date. It is useful for creating future dates, calculating deadlines and comparing previous reporting periods.
Syntax
DATEADD(date_part, interval, date)
Add 7 Days
DATEADD('day', 7, [Order Date])
Subtract 1 Month
DATEADD('month', -1, [Order Date])
Add 1 Year
DATEADD('year', 1, [Order Date])
Example Results
| Original Date | Expression | Result |
|---|---|---|
| 2026-11-04 | DATEADD('day', 7, date) | 2026-11-11 |
| 2026-11-04 | DATEADD('month', 1, date) | 2026-12-04 |
| 2026-11-04 | DATEADD('year', 1, date) | 2027-11-04 |
| 2026-11-04 | DATEADD('day', -5, date) | 2026-10-30 |
Practical Example: Delivery Deadline
DATEADD('day', 7, [Order Date])
This expression calculates a delivery deadline seven days after the order date.
9. DATE() Function
DATE() converts an expression into a date value when Tableau can interpret the expression as a date.
Syntax
DATE(expression)
Example
DATE([Order Date])
This expression converts the field into a Date value, removing the time portion when converting a Date & Time value to a date.
Example: Convert a Date & Time Field
DATE([Order Timestamp])
10. DATEPARSE() Function
DATEPARSE() converts a text value into a date using a specified format. It is useful when dates are stored as strings and Tableau cannot automatically interpret them.
Syntax
DATEPARSE(format, string)
Example: Day-Month-Year
DATEPARSE('dd-MM-yyyy', [Date Text])
Example: Year-Month-Day
DATEPARSE('yyyy-MM-dd', [Date Text])
Example: Month/Day/Year
DATEPARSE('MM/dd/yyyy', [Date Text])
Example Dataset
| Date Text | Format | Parsed Date |
|---|---|---|
| 04-11-2026 | dd-MM-yyyy | 2026-11-04 |
| 2026-11-04 | yyyy-MM-dd | 2026-11-04 |
| 11/04/2026 | MM/dd/yyyy | 2026-11-04 |
How to Create a Parsed Date
- Open the Tableau worksheet.
- Locate the text field containing date values.
- Create a new calculated field.
- Enter a meaningful name such as Converted Order Date.
- Write the DATEPARSE expression using the matching format.
- Click Apply or OK.
- Verify that Tableau recognizes the result as a date.
11. MAKEDATE() Function
MAKEDATE() creates a date value from separate year, month and day values. It is useful when date components are stored in different fields or numeric columns.
Syntax
MAKEDATE(year, month, day)
Example
MAKEDATE(2026, 11, 4)
Using Dataset Fields
MAKEDATE([Year], [Month], [Day])
Example
| Year | Month | Day | Created Date |
|---|---|---|---|
| 2026 | 11 | 4 | 2026-11-04 |
| 2026 | 12 | 15 | 2026-12-15 |
| 2027 | 1 | 10 | 2027-01-10 |
12. TODAY() and NOW() Functions
TODAY() and NOW() return the current date and current date-time values respectively. These functions are useful for dynamic reporting and time-sensitive calculations.
TODAY()
TODAY()
Returns the current date.
NOW()
NOW()
Returns the current date and time.
Practical Example: Days Since Order
DATEDIFF('day', [Order Date], TODAY())
This expression calculates the difference in day boundaries between an order date and the current date.
Practical Example: Days Until Delivery Deadline
DATEDIFF('day', TODAY(), [Delivery Deadline])
This expression calculates the difference in day boundaries between today and the delivery deadline.
Practical Example: Current Timestamp
NOW()
This can be used when the analysis needs the current date and time rather than only the date.
13. ISDATE() Function
ISDATE() checks whether a given expression can be interpreted as a valid date. It returns a Boolean result: True or False.
Syntax
ISDATE(expression)
Example
ISDATE([Date Text])
Example Results
| Date Text | ISDATE Result |
|---|---|
| 2026-11-04 | True |
| November 04, 2026 | True, if recognized by the environment |
| Not a date | False |
14. Practical Business Example: Order and Delivery Analysis
Consider an e-commerce company that wants to analyze its order processing and delivery performance. The dataset contains Order Date, Ship Date, Delivery Date and Sales.
Calculation 1: Extract Order Year
DATEPART('year', [Order Date])
Extracts the year from the order date.
Calculation 2: Extract Order Month Name
DATENAME('month', [Order Date])
Returns the month name for reporting.
Calculation 3: Monthly Order Period
DATETRUNC('month', [Order Date])
Groups dates into monthly periods.
Calculation 4: Shipping Duration
DATEDIFF('day', [Order Date], [Ship Date])
Calculates the difference in day boundaries between order and ship dates.
Calculation 5: Delivery Deadline
DATEADD('day', 7, [Order Date])
Calculates a date seven days after the order date.
Calculation 6: First Day of the Order Year
DATETRUNC('year', [Order Date])
Returns the first date of the order year.
Dashboard Creation Steps
- Connect Tableau to the order dataset.
- Check the data types of all date fields.
- Create calculated fields for the required date functions.
- Create a worksheet for monthly sales.
- Create a worksheet for yearly sales.
- Create a worksheet for shipping duration.
- Create a worksheet for delivery deadlines.
- Combine the worksheets into a dashboard.
- Add date filters for interactive analysis.
- Validate the calculations against the source data.
Example Order Performance Summary
Illustrative metrics based on the four sample orders used in this lesson.
15. Common Errors and Troubleshooting
| Problem | Possible Reason | Solution |
|---|---|---|
| Date function returns an error | Incorrect syntax or field reference. | Verify the function syntax and field names. |
| DATEPART returns unexpected values | Wrong date part or date field. | Check the date component being extracted. |
| DATENAME returns unexpected text | Locale or date-part settings differ. | Review the date format and locale settings. |
| DATEPARSE returns Null | Format string does not match source text. | Use the exact format of the source date string. |
| DATEDIFF gives unexpected results | Date-part boundary counting is misunderstood. | Check the date part and start/end date order. |
| DATEADD returns an unexpected date | Wrong interval or date part. | Verify the interval value and date part. |
| Date field is treated as text | Source data type is incorrect. | Convert or parse the text into a date value. |
| ISDATE returns False | Input cannot be interpreted as a date. | Check the source value and supported date format. |
16. Best Practices for Date Functions
- Verify that date fields have the correct data type.
- Use DATEPART() for numeric date components.
- Use DATENAME() for readable date-part names.
- Use DATETRUNC() for period-based grouping.
- Use DATEDIFF() for date-part difference calculations.
- Use DATEADD() for date interval calculations.
- Match DATEPARSE() formats with the original text.
- Validate results with sample records.
- Consider locale and week-start settings when analyzing weeks.
- Use clear names for date-related calculated fields.
- Check null values and invalid dates before analysis.
- Test date calculations using different reporting periods.
17. Practical Exercise
Use a sales dataset containing Order Date, Ship Date, Delivery Date, Customer and Sales fields. Complete the following tasks to practice Tableau date functions.
Exercise 1: Extract Year
Create a calculated field that extracts the order year.
DATEPART('year', [Order Date])
Exercise 2: Extract Month Name
Create a field that returns the order month name.
DATENAME('month', [Order Date])
Exercise 3: Create Monthly Period
Group all order dates into monthly periods.
DATETRUNC('month', [Order Date])
Exercise 4: Calculate Shipping Duration
Calculate the difference between order date and ship date.
DATEDIFF('day', [Order Date], [Ship Date])
Exercise 5: Calculate Delivery Deadline
Create a deadline seven days after the order date.
DATEADD('day', 7, [Order Date])
Exercise 6: Convert Text into Date
Convert a text field formatted as DD-MM-YYYY.
DATEPARSE('dd-MM-yyyy', [Date Text])
Exercise 7: Create a Date from Separate Fields
Combine Year, Month and Day into one date field.
MAKEDATE([Year], [Month], [Day])
Summary
Date Functions in Tableau help users extract, group, compare, modify and validate date and time values. DATEPART() extracts numeric date components, DATENAME() returns readable date-part names, DATETRUNC() groups dates at a specified level, DATEDIFF() calculates differences between dates and DATEADD() adds or subtracts date intervals. DATE(), DATEPARSE() and MAKEDATE() support date conversion and creation, while TODAY() and NOW() provide current date and date-time values. These functions are useful for monthly and yearly sales reports, delivery analysis, order processing and other time-based business calculations. In the next lesson, you will learn the difference between Continuous and Discrete Dates in Tableau.