cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
tbrantley
Level: Powered On

Calculating the difference between two times

Can someone help me with this forumula to calculate the difference between two times?

 

My formula in sharepoint is 24*(EndTime1-StartTime1). Not sure how to do this in Powerapps

 

Capture5.PNG

 

1 ACCEPTED SOLUTION

Accepted Solutions
PowerApps Staff AndyPennell
PowerApps Staff

Re: Calculating the difference between two times

DateDiff(StartTime1,EndTime1,Hours)
8 REPLIES 8
PowerApps Staff AndyPennell
PowerApps Staff

Re: Calculating the difference between two times

DateDiff(StartTime1,EndTime1,Hours)
Super User
Super User

Re: Calculating the difference between two times

Hi @AndyPennell and @tbrantley. How about this scenario? 

 

Two Date+Time cards: 

dateDiffWithHoursAndMinutes.png

 

Trying to use DateDiff between them to display hours and minutes in "##:##" format using: 

Concatenate(    
    Text(    
        DateDiff(
            DateTimeValue(
                    Concatenate(
                        Text(
                            startDate.SelectedDate,DateTimeFormat.ShortDate),
                        Char(13),
                        Text(
                            Concatenate(
                                startHour.Selected.Value,
                                ":",
                                startMinute.Selected.Value),ShortTime)),"en-US"),
            DateTimeValue(
                    Concatenate(
                        Text(
                            endDate.SelectedDate,DateTimeFormat.ShortDate),
                        Char(13),
                        Text(
                            Concatenate(
                                endHour.Selected.Value,
                                ":",
                                endMinute.Selected.Value),ShortTime)),"en-US"),
        Hours),"[$-en-US]##"),
        
        ":",
    Text(
        DateDiff(
            DateTimeValue(
                    Concatenate(
                        Text(
                            startDate.SelectedDate,DateTimeFormat.ShortDate),
                        Char(13),
                        Text(
                            Concatenate(
                                startHour.Selected.Value,
                                ":",
                                startMinute.Selected.Value),ShortTime)),"en-US"),
            DateTimeValue(
                    Concatenate(
                        Text(
                            endDate.SelectedDate,DateTimeFormat.ShortDate),
                        Char(13),
                        Text(
                            Concatenate(
                                endHour.Selected.Value,
                                ":",
                                endMinute.Selected.Value),ShortTime)),"en-US"),
        Minutes),"[$-en-US]##")
)

But this results in: 

dateDiffWithHoursAndMinutes1.png

 

How do I get the correct times to display? 


Thanks

WPB
Level 8

Re: Calculating the difference between two times

Works for me. Far from ideal but you know...

 

RoundDown(DateDiff(Date_Debut,Date_Fin,Seconds)/3600,0) 
& ":" &
RoundDown((DateDiff(Date_Debut,Date_Fin,Seconds)/3600 - RoundDown(DateDiff(Date_Debut,Date_Fin,Seconds)/3600,0))*60,0)
& ":" &
Round((DateDiff(Date_Debut,Date_Fin,Seconds)/60 - RoundDown(DateDiff(Date_Debut,Date_Fin,Seconds)/60,0))*60,0)
WPB
Level 8

Re: Calculating the difference between two times

Text(Time(0, 0, DateDiff(Punch_Record.Date_Debut,Now(),Seconds)), "[$-en-US]hh:mm:ss")

AndySid
Level 8

Re: Calculating the difference between two times

I needed to do this as well, and found this solution works well when using the hour and minute dropdown on a datacard....

 

DateDiff(Time(
Value(HourValue11.Selected.Value),
Value(MinuteValue11.Selected.Value),
0),Time(
Value(HourValue12.Selected.Value),
Value(MinuteValue12.Selected.Value),
0),Minutes) / 60.0

Nick_Loenders
Level: Powered On

Re: Calculating the difference between two times

Hi, I used your code and it kind of works

 

but for eg 1 hour and 10 minutes it shows: 1:70

so it adds the hour in minutes to the minutes??

How can I solve this?

Nick_Loenders
Level: Powered On

Re: Calculating the difference between two times

Hi @ericonline ,

 

I used your code and it kind of works

 

but for eg 1 hour and 10 minutes it shows: 1:70

so it adds the hour in minutes to the minutes??

How can I solve this?

Highlighted
Super User
Super User

Re: Calculating the difference between two times

Hi @Nick_Loenders ,

 

This thread was continued in another post. Check out @CarlosFigueira 's excellent response and sample app. This will fix you up!


Helpful resources

Announcements
firstImage

PowerApps Monthly Community Call!

Join us next Wednesday for our Demo Extravaganza, October 16, 2019 8am PDT.

firstImage

Microsoft Business Applications Virtual Launch Event

Join us for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

FirstImage

Power Platform World Tour

Coming to a city near you

thirdimage

PowerApps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

FourthImage

Join PowerApps User Group!!

Connect, share, and learn with your peers year-round

SecondImage

Power Platform Summit North America

Register by September 5 to save $200

Top Kudoed Authors
Users Online
Currently online: 357 members 4,328 guests
Please welcome our newest community members: