cancel
Showing results for
Did you mean:
Highlighted
Level: Powered On

## Calculate hours based on date field

See screenshot below. I would like to calculate the total number of hours based on the start time and end time. The day can not be adjusted.

Thanks

1 ACCEPTED SOLUTION

Accepted Solutions
Level: Powered On

## Re: Calculate hours based on date field

@v-micsh-msftThanks for your message. I solved it in a different way. See formula below.

Text(TimeValue(Concatenate(HourValue4.Selected.Value;":";MinuteValue4.Selected.Value)) - TimeValue(Concatenate(HourValue3.Selected.Value;":";MinuteValue3.Selected.Value)))/1000/60/60

2 REPLIES 2
Community Support Team

## Re: Calculate hours based on date field

Hi @Abdul1,

You could format the date time string, then use the DateDiff to calculate the Time difference.

For example, for the Start Time,

`Text(DateTimeValue(StartTime.Text)+Time(Value(StartHour.selected.value),Value(StartMinutes.Selected.Value,0))`

EndTime:

`Text(DateTimeValue(EndTime.Text)+Time(Value(EndHour.Selected.value),Value(EndMinutes.Selected.Value,0))`

Then take use of DateDiff() to calculate the difference:

```DateDiff (
DateTimeValue(Text(DateTimeValue(StartTime.Text)+Time(Value(StartHour.selected.value),Value(StartMinutes.Selected.Value,0))),
DateTimeValue(Text(DateTimeValue(EndTime.Text)+Time(Value(EndHour.Selected.value),Value(EndMinutes.Selected.Value,0))),
Hours
)
```

Regards,

Michael

Community Support Team _ Michael Shao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Level: Powered On

## Re: Calculate hours based on date field

@v-micsh-msftThanks for your message. I solved it in a different way. See formula below.

Text(TimeValue(Concatenate(HourValue4.Selected.Value;":";MinuteValue4.Selected.Value)) - TimeValue(Concatenate(HourValue3.Selected.Value;":";MinuteValue3.Selected.Value)))/1000/60/60

Announcements

#### PowerApps Monthly Community Call!

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

#### 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.

#### Watch Sessions On Demand!

Continue your learning in our online communities.

#### Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

#### Power Platform World Tour

Coming to a city near you

#### PowerApps Community User Group Member Badge

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

#### Join PowerApps User Group!!

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

#### Power Platform Summit North America

Register by September 5 to save \$200

Top Kudoed Authors
Users Online
Currently online: 523 members 5,176 guests
Recent signins: