cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
drallam2
Helper I
Helper I

Time Display Format

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!

1 ACCEPTED SOLUTION

Accepted Solutions
bdodu
Responsive Resident
Responsive Resident

Try this:

 

Text(RoundDown(DateDiff(CurrentTime,InitialTime,Seconds)/3600,0),"00")&":"&
Text(If(RoundDown(DateDiff(CurrentTime,InitialTime,Seconds)/60,0)>59,0,RoundDown(DateDiff(CurrentTime,InitialTime,Seconds)/60,0)),"00")&":"&
Text(Mod(DateDiff(CurrentTime,InitialTime,Seconds),60),"00")

 

View solution in original post

13 REPLIES 13
bdodu
Responsive Resident
Responsive Resident

show us the code you are using

Did you use the DateDiff?

Text(DateDiff(StartTime1,EndTime1,Seconds),"hh:mm:ss")

 

I'm using this to calculate seconds

(RoundDown((CurrentTime - InitialTime) * 24 * 60 * 60, 0))

Also The hh:mm:ss format doesn't work. I want to see the result like this.
Eg: we have320 seconds the result should be 00h:05m:20s

bdodu
Responsive Resident
Responsive Resident

CurrentTime & InitialTime are integer values or datetime?

are date time values using functions now()

Hi @drallam2

Do not use

 

(RoundDown((CurrentTime - InitialTime) * 24 * 60 * 60, 0))

  Use DateDiff to get seconds difference

 

DateDiff(InitialTime,CurrentTime,Seconds)

 

To get it to a format 00h:05m:20s you will have to be little more creative

 

Text(DateAdd(CurrentTime, DateDiff(CurrentTime,InitialTime,Seconds), Seconds),"hh") & "h:"
& Text(DateAdd(CurrentTime, DateDiff(CurrentTime,InitialTime,Seconds), Seconds),"mm") & "m:"
& Text(DateAdd(CurrentTime, DateDiff(CurrentTime,InitialTime,Seconds), Seconds),"ss") & "s"

Unfortunately. I'm not getting the same result. Example for a 2 second elapsed time. For some reason the time shows 9h:59m:58s

Sienna
Resident Rockstar
Resident Rockstar

Display CurrentTime and InitialTime in a labels and see what you get. Are the times correct? If not how do you set the currentTime and InitialTime
bdodu
Responsive Resident
Responsive Resident

Try this:

 

Text(RoundDown(DateDiff(CurrentTime,InitialTime,Seconds)/3600,0),"00")&":"&
Text(If(RoundDown(DateDiff(CurrentTime,InitialTime,Seconds)/60,0)>59,0,RoundDown(DateDiff(CurrentTime,InitialTime,Seconds)/60,0)),"00")&":"&
Text(Mod(DateDiff(CurrentTime,InitialTime,Seconds),60),"00")

 

Helpful resources

Announcements
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (4,358)