cancel
Showing results for 
Search instead for 
Did you mean: 
Subscribe

I'm trying to return the difference in hours and minutes between two DateTime fields.

I'm currently using the following

DateDiff ("n",{@DateTimeRecd},{@DateTimeRtd})

However, this only returns the number of mintues. Of course I can change it to DateDiff ("h",{@DateTimeRecd},{@DateTimeRtd}), but this is only hours.

I'm needing the time in hours and minutes.

Any ideas?

Thank you in advance for your assistance.

0 Likes
View Entire Topic
0 Likes

I'm pretty sure I got the logic right on this one, it's been a while but excusing typos, this should do it in one line.

iif(totext(DateDiff ("n",{@DateTimeRecd},{@DateTimeRtd}) \ 60)>0, totext(DateDiff ("n",{@DateTimeRecd},{@DateTimeRtd}) \ 60) + " Hours and ","") + iif(DateDiff ("n",{@DateTimeRecd},{@DateTimeRtd}) mod 60 <= 0, "No Minutes", totext(DateDiff ("n",{@DateTimeRecd},{@DateTimeRtd}) - (DateDiff ("n",{@DateTimeRecd},{@DateTimeRtd}) \ 60)) + " minutes")

Thanks,

Zach

Former Member
0 Likes

I tried this and get a message stating a string is required. It then highlights the 0 directly after the > in the first statement.

iif(totext(DateDiff ("n",{@DateTimeRecd},{@DateTimeRtd}) \ 60)>0, totext(DateDiff ("n",{@DateTimeRecd},{@DateTimeRtd}) \ 60) + " Hours and ","") + iif(DateDiff ("n",{@DateTimeRecd},{@DateTimeRtd}) mod 60 <= 0, "No Minutes", totext(DateDiff ("n",{@DateTimeRecd},{@DateTimeRtd}) - (DateDiff ("n",{@DateTimeRecd},{@DateTimeRtd}) \ 60)) + " minutes")

kyle_mcadam
Product and Topic Expert
Product and Topic Expert
0 Likes

Get rid of the Totext() in the first statement, because you are comparing that against 0. The toText is only necessary in the two optional results.