2 Replies Latest reply on Jan 25, 2017 8:12 AM by Lior Gil

# Exact Date difference Calculation

Hi All,

I'd like calculate the difference between start date and end date

and created calculated filed:

ATTR(datediff('year', [Start date],[End date]))

for example:

start date - 1.9.2006

end date - 31.12.2016

the result : 10.00

the result is not accurate, as I need the exact difference which is - 10 years and 4 month

can Tableau calculate it?

Lior

• ###### 1. Re: Exact Date difference Calculation

Hi Loir,

Since you specified 'year' in the datediff function, Tableau will only calculate the year differences.  You could either calculate the differences in month, or calculate the year differences, and then add the month differences - (year differences * 12) to get year and month difference.

Kind regards,

Wim

• ###### 2. Re: Exact Date difference Calculation

Hi Wim,

Actually i found the answer right after I posted the question, just used this equation which gave me exactly what I need:

attr(round([End date] - [Start date], 0))/365

Thanks,

Lior