Tableau - Date Differences

Find the difference between two dates using DATEDIFF


                    DATEDIFF(date_part, start_date, end_date, [start_of_week])
                     

The date_part can be:

  • day
  • week
  • month
  • quarter
  • year

[start_of_week] is an optional parameter which can be any day of the week (i.e "Monday", "Tuesday", etc)

Example

Find the number of months between two specified dates


                    DATEDIFF('month',#2017-07-01#, #2017-09-01#)
                     

Find the number of days between two specified dates


                    DATEDIFF('day',#2017-01-01# , TODAY())
                     

Some tips:

  • Change data type to date
  • Change data type to discrete

DATEDIFF with DATETRUNC lets you track date differences without hard coding a specific date.


Dash-Intel is a Power BI and Tableau resource site for data visualization and building BI dashboards.

Data Analyst & Consultant

Copyright 2015-2023 Dash-Intel.com Terms