DateDiff() function help - Dates in 2 different columns

34,163

Solution 1

I am not sure exactly what your data looks like, but you could calculate the difference in days between two dates by using the datediff function.

I am using this calculation: DATEDIFF('day',[Order Date],[Ship Date])

You can easily recreate this with the sample data set (superstore) that ships with tableau.

enter image description here

Solution 2

Please use attr(DATEDIFF('day',[Order Date],[Ship Date]))

you will get the correct answer

Share:
34,163
cg529d
Author by

cg529d

Updated on July 09, 2022

Comments

  • cg529d
    cg529d almost 2 years

    I am trying to write a function to enable Tableau to calculate the difference between 2 dates, however they are in 2 different columns and I am having a bit of trouble.

    Example:

    Column 1

    First Opened Date - 10/01/2014

    Column 2

    Reviewed Date - 15/01/2014

    Obviously from this example there is 5 days between the two different columns.

    These columns are aligned in rows due to a unique ID.

    Any help would be much appreciated!

    Thanks Ellie