Is there an easy way to calculate a duration from start to end displayed in hours **and** minutes? I've only seen mention of either/or. I've tried a few things unsuccessfully. Essentially I just want ${EndTime} - ${StartTime} in a h:mm format. So, if I have StartTime = 12:00PM and EndTime = 2:06PM, I want Duration to be 2:06, not 2.1 hours or 126 minutes.

Hi Brian,

This is pretty straightforward if a little tedious. First to note is that time is stored internally in the Survey123 app in milliseconds (ms). 1000 ms = 1 sec = 1/60 min = 1/3600 hr. This leads to:

# of hours = time elapsed / (3600*1000) > take the integer of the result

# of minutes (total) = time elapsed / (60*1000) > then use the modulo operation with 60 (mod 60) to get the number of minutes under a whole hour

A small thing to remember visually is to pad a zero if the number of minutes is less than 10

The Excel sheet attached steps through the formulas; all together the function (assuming the end question is t2 and the start question is t1:

concat(int((${t2} - ${t1}) div (1000*60*60)), ":", if(int(((${t2} - ${t1}) div (1000*60)) mod 60) < 10,"0",""), int(((${t2} - ${t1}) div (1000*60)) mod 60))