Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Apps - Building Power Apps
Answered

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:
  • IanSL Profile Picture
    6 on at
    Re: Displaying minutes elapsed between two date time fields in text box

    Perfect! Thank you so much!

    IanSL_2-1706540014146.png

     

  • Verified answer
    WarrenBelz Profile Picture
    148,648 Most Valuable Professional on at
    Re: Displaying minutes elapsed between two date time fields in text box

    @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

  • zuurg Profile Picture
    530 Super User 2024 Season 1 on at
    Re: Displaying minutes elapsed between two date time fields in text box

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

  • IanSL Profile Picture
    6 on at
    Re: Displaying minutes elapsed between two date time fields in text box

    IanSL_0-1706307614729.png

    IanSL_1-1706307626630.png

     

  • WarrenBelz Profile Picture
    148,648 Most Valuable Professional on at
    Re: Displaying minutes elapsed between two date time fields in text box

    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

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

Paul Stork – Community Spotlight

We are honored to recognize Paul Stork as our July 2025 Community…

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 791 Most Valuable Professional

#2
MS.Ragavendar Profile Picture

MS.Ragavendar 410

#3
mmbr1606 Profile Picture

mmbr1606 275 Super User 2025 Season 1