web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / DateDiff Hours Minutes...
Power Apps
Answered

DateDiff Hours Minutes AND Seconds

(0) ShareShare
ReportReport
Posted on by 1,146

Thank you for taking the time to read my question.

 

I'm wondering how to use DateDiff() to calculate the hours, minutes and seconds between the first record in my collection and the last record in my collection.

 

I found a post to do the hours and minutes which works, but I tried to keep the same format and add seconds but it's not working as expected.

 

If a few seconds pass, I also get a value for the minutes.

 

Here is my code... am I close?

 

If(IsEmpty(colLocHist),"","Travel Time: " & DateDiff(First(colLocHist).CaptureDateTime,Last(colLocHist).CaptureDateTime,Hours) & ":" & If(Len(Text(Mod(DateDiff(First(colLocHist).CaptureDateTime,Last(colLocHist).CaptureDateTime,Minutes),60)))=1,"0"&Mod(DateDiff(First(colLocHist).CaptureDateTime,Last(colLocHist).CaptureDateTime,Minutes),60),Mod(DateDiff(First(colLocHist).CaptureDateTime,Last(colLocHist).CaptureDateTime,Minutes),60))) & ":" & If(Len(Text(Mod(DateDiff(First(colLocHist).CaptureDateTime,Last(colLocHist).CaptureDateTime,Seconds),60)))=1,"0"&Mod(DateDiff(First(colLocHist).CaptureDateTime,Last(colLocHist).CaptureDateTime,Seconds),60),Mod(DateDiff(First(colLocHist).CaptureDateTime,Last(colLocHist).CaptureDateTime,Seconds),60))

 

 

Thanks!

Categories:
  • iwonder Profile Picture
    1,146 on at

    I just realized I could simplify to this:

     

    If(IsEmpty(colLocHist),"","Travel Time: " & DateDiff(First(colLocHist).CaptureDateTime,Last(colLocHist).CaptureDateTime,Hours) & ":" & Text(Mod(DateDiff(First(colLocHist).CaptureDateTime,Last(colLocHist).CaptureDateTime,Minutes),60),"00") & ":" & Text(Mod(DateDiff(First(colLocHist).CaptureDateTime,Last(colLocHist).CaptureDateTime,Seconds),60),"00")
  • Verified answer
    iwonder Profile Picture
    1,146 on at

    Got it:

     

    If(IsEmpty(colLocHist),"","Travel Time: " & DateDiff(First(colLocHist).CaptureDateTime,Last(colLocHist).CaptureDateTime,Hours) & ":" & Text(Mod(DateDiff(First(colLocHist).CaptureDateTime,Last(colLocHist).CaptureDateTime,Minutes),60),"00") & ":" & Text(Mod(Mod(DateDiff(First(colLocHist).CaptureDateTime,Last(colLocHist).CaptureDateTime,Seconds),60),60),"00"))
  • iwonder Profile Picture
    1,146 on at

    ...Actually I didn't

     

    07/08/2021 16:22:49

    07/08/2021 16:23:15

     

    returns: 0:01:26

     

    Do I need to determine total seconds and then calculate back the minutes and hours?

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 352 Super User 2026 Season 2

#2
M Bilal Khan Profile Picture

M Bilal Khan 323

#3
Mohsin Ali Profile Picture

Mohsin Ali 226

Last 30 days Overall leaderboard