cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Anonymous
Not applicable

Calculate difference between dates! Help!

Hello Guys, im having a really hard times now in PowerApps trying to calculate the difference between two dates to get the results in Hour.

I have been looking around for many hours trying to solve this but no success...

 

I have this Dates and Hours information

 

Parada is the first

Liberação is the last

 

I need to do an = Liberação - Parada, and get the results in 00:00:00, in this case it would be about 03:00:00 hours..

I tried the DateDiff, but it resulted in -27, he considered 1 day and 3 hours...this is not what I want.

hourcalculatepowerapps.PNG

 

The formulas I need to use to bring the correct date is 

Parada Text Label = "Parada " & Text ( DateAdd(Parada; TimeZoneOffset(Parada);Minutes) ; "[$-pt-BR]dd/mm/yyyy hh:mmSmiley Frustrateds" ; "pt-BR" )

Liberação Text Label = "Liberação "  & Text ( DateAdd(Liberação; TimeZoneOffset(Liberação);Minutes) ; "[$-pt-BR]dd/mm/yyyy hh:mmSmiley Frustrateds" ; "pt-BR" )

 

I appreciated any helps!

 

3 REPLIES 3
Super User
Super User

Re: Calculate difference between dates! Help!

Hi @Anonymous, 

 

I recently went through the same exercise. You're correct, its not simple to diff dates and times in HH:MM format but it IS possible Smiley Happy. Please see the thread here: https://powerusers.microsoft.com/t5/General-Discussion/Need-help-with-diffing-times-commented-code/m-p/136077#M47070. 

 

@CarlosFigueira and I went through a lot of work to document how to do this. 

 

Hope this helps!

Anonymous
Not applicable

Re: Calculate difference between dates! Help!

Hi Erico, thanks for the reply.

 

It for sure gave me a north to this issue.

 

But Now I Im having another problem because of my form format.

On the create new form, i needed to adapt it because my users are using it on Desktop, so The Hour/Minute picker was terrible to choose, so i adapted it so they can write the hour/minte by theirselves.

 

thptotal.PNG

This is not the problem, because i could adapt the formula you instructed me, to this scenario.

 

The actual problem is, on the edit screen, I needed to change the way they fill the dates, because I couldnt do the hour/minute shows on the excel file correctly.edit_page.PNGthp_result.PNG

 

So the problem starts now, when the form is edited, the formula loses the reference of the Hour/minute field, and calculates nothing, and do not update Smiley Sad

 

Any idea how can I solve this?

Super User
Super User

Re: Calculate difference between dates! Help!

Hm. I'm having trouble understanding the issue. 

 

  • I see you adjusted the Hour/Minute input fields from a Dropdown to a text box. 
  • You likely have to change all of the parts of the Hour / Minute Formulas from ".Selected.Value" to ".Text"

 

Hope this helps!

 

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: 315 members 5,002 guests
Please welcome our newest community members: