Hi,
I'm having trouble with converting seconds to hh:mm:ss format in a text display.
I'm calculating the seconds based on the difference between two time stamps.
anyhelp will be great!
Solved! Go to Solution.
Just wanted to point something out. I came across this post while I was trying to solve the same problem. Although the marked solution is close, there's a problem with the minutes calculation. When the timer goes over an hour the If statement returns only 0. The corrected solution which will include the minutes calculation past the 1 hour mark should be:
Text(RoundDown(UpdateTimer/3600,0),"[$-en-US]00")&":"&
Text(If(RoundDown(UpdateTimer/60,0)>59,
RoundDown((UpdateTimer-(RoundDown(UpdateTimer/3600,0)*3600))/60,0),
RoundDown(UpdateTimer/60,0)),"[$-en-US]00")&
":"&
Text(Mod(UpdateTimer,60),"[$-en-US]00")
FYI on this formula, I have the DateDiff function running in a timer somewhere else in my program. Anywhere you see "UpdateTimer" in the equation above you can replace it with: DateDiff(TimeValue(TimerClockIn),TimeValue(Text(Now(),"[$-en-US]hh:mm:ss")),Seconds). However I think PowerApps runs it better when you split that function out, store its' result in a variable, then manipulate it from there. Of course there are syntax's that you could use to eliminate the If statement as well, but I like telling it to use the less intensive formula when it can in order to conserve resources. Maybe I'm not really accomplishing that here(I'm not used to scripting languages), but it feels like it so I'm happy.
Hope that helps save someone hours of banging their head against the wall! 🙂
If you have got time as integer in seconds, e.g. 54977 seconds and you want to have time in 24h format:
15:16:17
you can use:
Text(
RoundDown(
ThisItem.Time / 3600;
0
)
) & ":" &
//mm
Text(
RoundDown(
(ThisItem.Time / 3600 - (RoundDown(
ThisItem.Time / 3600;
0
))) * 60;
0
)
) & ":" &
//ss
Text(
(((ThisItem.Time / 3600 - (RoundDown(
ThisItem.Time / 3600;
0
))) * 60)- RoundDown(
(ThisItem.Time / 3600 - (RoundDown(
ThisItem.Time / 3600;
0
))) * 60;
0
))*60
)
Thanks @bdodu for your suggestion... but looking at the formula I found an error which made minutes become 0 if the time was >1h... and found an easier way to do it.
Text(RoundDown(DateDiff(CurrentTime,InitialTime,Seconds)/3600,0),"00")&":"&
Text(RoundDown(Mod(DateDiff(CurrentTime,InitialTime,Seconds),3600)/60,0),"00")&":"&
Text(Mod(DateDiff(CurrentTime,InitialTime,Seconds),60),"00")
What if I wanted to display the date with this?
DD:HH:MM:SS
User | Count |
---|---|
125 | |
87 | |
87 | |
75 | |
69 |
User | Count |
---|---|
215 | |
181 | |
140 | |
97 | |
83 |