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 / Displaying minutes ela...
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:
I have the same question (0)
  • WarrenBelz Profile Picture
    156,047 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
    546 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
    156,047 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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 352 Most Valuable Professional

#2
11manish Profile Picture

11manish 192

#3
Valantis Profile Picture

Valantis 128

Last 30 days Overall leaderboard