DateDiff - anyone know more?

Can someone help me get a better understanding of the datediff function?
Is there a start and end date? or is it just the delta between the dates? (meaning if the start date is after the end date the value will be negative)
If I do not specify a period, will the function return only whole numbers in days or partial numbers too? (1.5 days, 0.5 days and so on)
any help will be appreciated!

Hi @eyagel, the documentation for dateDiff is here.
You need to supply two dates. If the second date is earlier than the first you will get a negative.
By default the value returned is the number of days, but you can specify other periods such as month, or hours.

1 Like

Hi @eyagel ,
As per my understanding the dateDiff function has the syntax like dateDiff(Start Date, End Date, ‘Date Period’). As per your choice you can put your Date Period if you not put any Date period then by default QuickSight give you the duration between two Date as Days only.

Yes if you placed the Start Date after the End Date then it will give you the Negative values as Days.

The dateDiff function returns by default as Sum aggregation so you need to change it into Avg (It will give you the fraction Number).

Min(Give you the whole number)

Please have a look with this snap for better understanding.


If you required more then please go through the below documents

Thanks & Regards
Biswajit Dash

1 Like

Thanks this is great!

Another small question, I am not aggregating the differences rather puting the function in a ifelse statement then aggregating that result (as a boolean). will I need to average the datedif function in the ifelse to get the a fraction number?