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 / Displaying minutes ela...
Power Apps
Unanswered

Displaying minutes elapsed between two date time fields in text box

(0) ShareShare
ReportReport
Posted on by 6

IanSL_0-1706301576900.png

IanSL_1-1706301587613.png

IanSL_2-1706301603526.png

Set(varStartDateTime, DateAdd(CleanStartDate.SelectedDate, Time(Value(CleanStartHour.Selected.Value), Value(CleanStartMinute.Selected.Value), 0)));
Set(varEndDateTime, DateAdd(CleanEndDate.SelectedDate, Time(Value(CleanEndHour.Selected.Value), Value(CleanEndMinute.Selected.Value), 0)));
 

For some reason this is not working, 

 

Categories:
I have the same question (0)
  • WarrenBelz Profile Picture
    153,026 Most Valuable Professional on at

    Hi @IanSL ,

    Try this format

    With(
     {
     _Days: 
     DateDiff(
     CleanStartDate.SelectedDate + 
     Time(
     Value(CleanStartHour.Selected.Value),
     Value(CleanStartMinute.Selected.Value),
     0
     ),
     CleanEndDate.SelectedDate + 
     Time(
     Value(CleanEndHour.Selected.Value),
     Value(CleanEndMinute.Selected.Value),
     0
     ),
     TimeUnit.Minutes
     ) / 1440
     },
     With(
     {
     _Hours: 
     Mod(
     _Days,
     RoundDown(
     _Days,
     0
     )
     ) * 24
     },
     "Days: " & 
     RoundDown(
     _Days,
     0
     ) & " Hours: " & 
     RoundDown(
     _Hours,
     0
     ) & " Minutes: " & 
     Mod(
     _Hours,
     RoundDown(
     _Hours,
     0
     )
     ) * 60
     )
    )

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

    MVP (Business Applications)   Visit my blog Practical Power Apps

  • IanSL Profile Picture
    6 on at

    IanSL_0-1706307614729.png

    IanSL_1-1706307626630.png

     

  • zuurg Profile Picture
    535 Super User 2024 Season 1 on at

    If both dates & times are already properly formatted DateTime elements (like Now()) You can simply use DateDiff(datetime1,datetime2,TimeUnit.Minutes) 

  • Verified answer
    WarrenBelz Profile Picture
    153,026 Most Valuable Professional on at

    @IanSL ,

    That was a division by zero issue - here is a different approach - this one should work

    With(
     {
     _Calc: DateDiff(
     CleanStartDate.SelectedDate + Time(
     Value(CleanStartHour.Selected.Value),
     Value(CleanStartMinute.Selected.Value),
     0
     ),
     CleanEndDate.SelectedDate + Time(
     Value(CleanEndHour.Selected.Value),
     Value(CleanEndMinute.Selected.Value),
     0
     ),
     TimeUnit.Minutes
     )
     },
     With(
     {
     _Days: RoundDown(
     _Calc / 1440,
     0
     ),
     _DayMins: Mod(
     _Calc,
     1440
     )
     },
     With(
     {
     _Hours: RoundDown(
     _DayMins / 60,
     0
     ),
     _Minutes: Mod(
     _DayMins,
     60
     )
     },
     _Days & " Days " & _Hours & " Hours " & _Minutes & " Minutes"
     )
     )
    )

    If you simply want the minutes, then just use this

    DateDiff(
     CleanStartDate.SelectedDate + Time(
     Value(CleanStartHour.Selected.Value),
     Value(CleanStartMinute.Selected.Value),
     0
     ),
     CleanEndDate.SelectedDate + Time(
     Value(CleanEndHour.Selected.Value),
     Value(CleanEndMinute.Selected.Value),
     0
     ),
     TimeUnit.Minutes
    )

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

    MVP (Business Applications)   Visit my blog Practical Power Apps

  • IanSL Profile Picture
    6 on at

    Perfect! Thank you so much!

    IanSL_2-1706540014146.png

     

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 796 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 327 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard