Advent of Code is back! Unwrap daily challenges to sharpen your Alteryx skills and earn badges along the way! Learn more now.
Free Trial

Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.
SOLVED

Date Difference - x Days x Hours

Not applicable

I'm trying to calculate the number of days and hours between two date fields. It looks like many are calculating correctly, but there are some that are showing days and then negative hours. Can anyone help spot why I'm getting those negative numbers?

 

Source data and workflow attached.

 

Thanks!!

3 REPLIES 3
jrgo
14 - Magnetar

Use this formula on expression [Display Diff]

 

TOSTRING(FLOOR(TONUMBER([HoursDiff] / 24)))
+' days '
+ TOSTRING(TONUMBER(MOD([HoursDiff], 24)))
+ ' hours'

 

If that works for you, you can remove the [Days Diff] and [Hours Only] expressions.

apathetichell
19 - Altair

you could be using datetimediff to calculate days. your formula for hours remaining should be

 

DateTimeDiff([Completed On], [Date / Time of Incident], "hours") - (DateTimeDiff([Completed On], [Date / Time of Incident], "days")*24)

 

I believe this is what you want.

Not applicable

Thank you. Worked like a charm.

Labels
Top Solution Authors