In case you missed the announcement: The Alteryx One Fall Release is here! Learn more about the new features and capabilities here
ACT NOW: The Alteryx team will be retiring support for Community account recovery and Community email-change requests after December 31, 2025. Set up your security questions now so you can recover your account anytime, just log out and back in to get started. Learn more here
Start 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
20 - Arcturus

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