I have a form that captures time related to water main break.
Time called out, time system shut down and time system is in back in service. Each of these values is stored in a time field.
To calculate the water loss in minutes I'm using int((${TimeSysShutDown}-${TimeCalled}) div (1000*60))
To calculate the length of the shutdown I'm using int((${TimeSysBackInService}-${TimeSysShutDown}) div (1000*60))
If the water gets shutdown at 1030 pm and turned back on at 130 am the calculation show -1270 minutes when it should show 180 minutes.
How do I set this up to capture the correct number of minutes when time crosses midnight?
Solved! Go to Solution.
Hi Mike,
One way would be to use a datetime field rather than time; this would also be the way to support shutdowns that last more than a day.
Another would be to use an if statement that checks for the end time being later than the start, and then proceeds to add 24 hours to the result. For the water loss calculation
int((${TimeSysShutDown}-${TimeCalled}) div (1000*60)) + if(${TimeCalled}>${TimeSysShutDown}, 1000*60*60*24, 0)
Hi Mike,
One way would be to use a datetime field rather than time; this would also be the way to support shutdowns that last more than a day.
Another would be to use an if statement that checks for the end time being later than the start, and then proceeds to add 24 hours to the result. For the water loss calculation
int((${TimeSysShutDown}-${TimeCalled}) div (1000*60)) + if(${TimeCalled}>${TimeSysShutDown}, 1000*60*60*24, 0)
Hi Mike,
Time is tough to deal with as outlined in this ArcGIS Blog post highlighted by Kelly Gerrow
That post includes a link to this superb youtube video:
The Problem with Time & Timezones - Computerphile - YouTube
I hope it helps you with midnight and the inevitable other headaches of calculating time,
-Bill