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

Notifications

Announcements

Community site session details

Community site session details

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

DateDiff Hours Minutes AND Seconds

(0) ShareShare
ReportReport
Posted on by 1,142

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:
I have the same question (0)
  • iwonder Profile Picture
    1,142 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,142 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,142 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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 717 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 329 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard