Showing Elapsed Time in HH:MM:SS format
I had a view where I wanted to show elapsed time in a H:MM:SS format (like 1:15:25 for 1 hour, 15 minutes, 25 seconds). When you subtract two date-time values, the result comes back in seconds. So it's a matter of converting that to hours, minutes, and seconds. And I also put in a special check to see if the time difference was less than 1 hour (3600 seconds). If it was, I put the format in M:SS (minutes and seconds with no leading zero on the minutes) instead of having "0" for the hours. The date/time fields are called "StartingTime" and "EndingTime". Here's the formula I came up with:S := EndingTime - StartingTime;
M1 := @Integer(S / 60);
S1 := S - (M1 * 60);
H2 := @Integer(S / 3600);
M2 := @Integer((S - (H2 * 3600)) / 60);
S2 := S - (H2 * 3600) - (M2 * 60);
@If(S < 3600; @Text(M1) + ":" + @Right("0" + @Text(S1); 2); @Text(H2) + ":" + @Right("0" + @Text(M2); 2) + ":" + @Right("0" + @Text(S2); 2))
Hope this proves useful to someone besides me.