3 Replies Latest reply on Jul 13, 2018 8:52 AM by Ken Flerlage

# DateDiff Help

This one is probably an easy question for some of you super users, but I am struggling and cannot find anything online that would tell me what I want.

I'm using the datediff function, trying to calculate the total number of hours between two date/time stamps.  I want the TOTAL number of hours. Below is an example of my data, and what I see.

I'm using the following two calculated fields to calculate my numbers below.

Rapid Check:

IIF([Status Changed To Hold Auth At] > [Asset Checked In At], DATEDIFF('hour',[Asset Checked In At],[Status Changed To Hold Auth At]),Null)

LOD Function: {FIXED [Case Id]: AVG([Rapid Check])}

The 86.615 is correct, however, if you look at the data below, you will notice that it is an average of the rounded hours!

The yellow highlighted field is what I calculate in Excel, which is what I would like to see in Tableau.  Here you can see the TOTAL number of hours for each case.  In the Blue section, it is only giving me the hours, not anything past the decimal point.

How can I get the EXACT number of hours, like in the yellow column to show in Tableau?  I've tried changing it to minutes, and it does the same thing (minutes: 5,187.00)!

Any help would be greatly appreciated.

Thanks

• ###### 1. Re: DateDiff Help

DATEDIFF will give you a whole number, so if you pass it "hour", it will round that hour. If you want decimal values, then change it to the following:

DATEDIFF('minute',[Asset Checked In At],[Status Changed To Hold Auth At])/60

This should give you a decimal value, measured in hours. Does that make sense?

1 of 1 people found this helpful
• ###### 2. Re: DateDiff Help

ah, ok. that is what I needed! Thank you for your help!@

• ###### 3. Re: DateDiff Help

Great. If you wouldn't mind, please mark the answer as the "correct answer" so that we can close this thread and others with similar questions in the future may learn from it. Thanks!!