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

Hours between dates

Hi

 

It is possible calculate hours between dates? I could calculate days between dates

2016-07-14_12-32-32.png

1 ACCEPTED SOLUTION

Accepted Solutions
hngdev
Level 8

Re: Hours between dates

Assume that you already had validation, you can try this:

DateDiff(DateTimeValue(TextBox1.Text), DateTimeValue(TextBox2.Text)) * 24 + Hour(DateTimeValue(TextBox1.Text)) -   Hour(DateTimeValue(TextBox2.Text))

5 REPLIES 5
hngdev
Level 8

Re: Hours between dates

Assume that you already had validation, you can try this:

DateDiff(DateTimeValue(TextBox1.Text), DateTimeValue(TextBox2.Text)) * 24 + Hour(DateTimeValue(TextBox1.Text)) -   Hour(DateTimeValue(TextBox2.Text))

Jamarchi
Level: Powered On

Re: Hours between dates

Hi hngdev

 

Excellent, it worked great, thank you very much

 

Regards,

hngdev
Level 8

Re: Hours between dates

You're welcome

Highlighted
Americo2018
Level: Powered On

Re: Hours between dates

Hi

 

Your code may be usefull for me if is there a way to exclude weekends and holidays, How could I get that?

 

Regadrs

Americo

PowerApps Staff CarlosFigueira
PowerApps Staff

Re: Hours between dates

The post at https://blogs.msdn.microsoft.com/carlosfigueira/2017/09/23/excluding-weekends-and-holidays-in-date-d... shows how to exclude weekends and holidays from date differences in PowerApps. Take a look and see how it can apply to your case.

 

Hope this helps!