I've seen this question a number of times so I've tried to put together a couple of simple options including one slightly dirty calculation that should get the job done
-If your elapsed time will be less than 24 hours, consider using the Time() function.
-If you can use a totalizer tag for your timer, you can use the Elapsed Time Widget
-If you are reading the elapsed number of seconds from a PLC or similar, you can check out the below formula which can be put into an expression in a text box.
{HH:mm:ss}
Replace(Concat(
Format(2,0,Int([<TimeRunning>]/3600)), {HH}
":",
Format(2,0,(Int([<TimeRunning>]%3600/60))), {mm}
":",
Format(2,0,[<TimeRunning>]%60) {ss}
),0,8," ","0")
Where [<TimeRunning>] is a tag getting the elapsed time in seconds.
Here is a similar thing in a slightly more difficult to read but more efficient way:
{HHHH:mm:ss}
Replace(Concat(
Format(4,0,Int([<TimeRunning>]/3600) {HHHH}),
":",
Time([<TimeRunning>] % 3600, "mm:ss" {mm:ss})
),0,10," ","0")
I've seen this question a number of times so I've tried to put together a couple of simple options including one slightly dirty calculation that should get the job done :)
-If your elapsed time will be less than 24 hours, consider using the _Time()_ function.
-If you can use a totalizer tag for your timer, you can use the _Elapsed Time Widget_
-If you are reading the elapsed number of seconds from a PLC or similar, you can check out the below formula which can be put into an expression in a text box.
````
{HH:mm:ss}
Replace(Concat(
Format(2,0,Int([<TimeRunning>]/3600)), {HH}
":",
Format(2,0,(Int([<TimeRunning>]%3600/60))), {mm}
":",
Format(2,0,[<TimeRunning>]%60) {ss}
),0,8," ","0")
````
Where [<TimeRunning>] is a tag getting the elapsed time in seconds.
Here is a similar thing in a slightly more difficult to read but more efficient way:
````
{HHHH:mm:ss}
Replace(Concat(
Format(4,0,Int([<TimeRunning>]/3600) {HHHH}),
":",
Time([<TimeRunning>] % 3600, "mm:ss" {mm:ss})
),0,10," ","0")
````
Trihedral Engineering Ltd.
edited Apr 13 '21 at 1:03 am