cancel
Showing results for
Did you mean:
Frequent Visitor

## DateDiff - Hours and Minutes

Hi all,

I have 2 multi-choice boxes (not time pickers) with a 'Start Time' and 'End Time'.  Someone on here kindly helped me work out the hours between the selected times but I also need minutes....if possible.

On the example below, I would like it to show minutes and hours e.g. 1.5 hour or 1.30  rather than just the hours

``````If(DataCardValue42.Selected.Value = "Work", DateDiff (
DateTimeValue (DataCardValue33.Selected.Value),
DateTimeValue (DataCardValue34.Selected.Value),
"hours"
))``````

1 ACCEPTED SOLUTION

Accepted Solutions
Community Support

Hi @Ian-S :

The reason is that the unit you use when calculating is 'hours'. Just replace it with minutes and divide by 60.

``````If(DataCardValue42.Selected.Value = "Work",
DateDiff (
DateTimeValue (DataCardValue33.Selected.Value),
DateTimeValue (DataCardValue34.Selected.Value),
Minutes
)/60
)``````

Best Regards,

Bof

5 REPLIES 5
Impactful Individual

(datediff(, hours) - RoundDown(datediff, hours))  * 60

this will give you min..

formula obvio not complete but you get the idea

Frequent Visitor

Thanks CDS.  I am not sure about the code???   (this is all very new to me).   Is the RoundDown(datediff, hours))  * 60 in addition to my existing code??

Sorry for being stupid!

Community Support

Hi @Ian-S :

The reason is that the unit you use when calculating is 'hours'. Just replace it with minutes and divide by 60.

``````If(DataCardValue42.Selected.Value = "Work",
DateDiff (
DateTimeValue (DataCardValue33.Selected.Value),
DateTimeValue (DataCardValue34.Selected.Value),
Minutes
)/60
)``````

Best Regards,

Bof

Regular Visitor

Credit for this has to Go to Shane Young - with this video - Power Apps Date Time Math - Do calculations for payroll and timesheets - YouTube

I used a field to collate both start time and minutes then end time and minutes and used the following:

With({minutesbetween:
DateDiff(TimeValue('Input - Start Time'.Text),TimeValue('Input - EndTime_2'.Text), Minutes) },
With({minutesleftover: Mod(minutesbetween, 60)},
(minutesbetween - minutesleftover)/60 & ":" &minutesleftover))

this will then give the number of hours difference in a time format e.g 7:25 minutes difference rather than 7.4444

Regular Visitor

Try the following code it should work:

In my case DateValue14. is the time out, DateValue13 is the time in

RoundDown(Text(DateDiff(DateValue14.SelectedDate+Time(Value(HourValue10.Selected.Value),Value(MinuteValue13.Selected.Value),0),DateValue15.SelectedDate+Time(Value(HourValue11.Selected.Value),Value(MinuteValue14.Selected.Value),0),TimeUnit.Minutes)/60),0)&" Hours : "&Mod(DateDiff(DateValue14.SelectedDate+Time(Value(HourValue10.Selected.Value),Value(MinuteValue13.Selected.Value),0),DateValue15.SelectedDate+Time(Value(HourValue11.Selected.Value),Value(MinuteValue14.Selected.Value),0),TimeUnit.Minutes),60)& " Minutes"

Good luck

Announcements

#### Celebrating the May Super User of the Month: Laurens Martens

@LaurensM  is an exceptional contributor to the Power Platform Community. Super Users like Laurens inspire others through their example, encouragement, and active participation. We are excited to celebrated Laurens as our Super User of the Month for May 2024.   Consistent Engagement:  He consistently engages with the community by answering forum questions, sharing insights, and providing solutions. Laurens dedication helps other users find answers and overcome challenges.   Community Expertise: As a Super User, Laurens plays a crucial role in maintaining a knowledge sharing environment. Always ensuring a positive experience for everyone.   Leadership: He shares valuable insights on community growth, engagement, and future trends. Their contributions help shape the Power Platform Community.   Congratulations, Laurens Martens, for your outstanding work! Keep inspiring others and making a difference in the community!   Keep up the fantastic work!

#### Announcing Power Apps Copilot Cookbook Gallery

We are excited to share that the all-new Copilot Cookbook Gallery for Power Apps is now available in the Power Apps Community, full of tips and tricks on how to best use Microsoft Copilot as you develop and create in Power Apps. The new Copilot Cookbook is your go-to resource when you need inspiration--or when you're stuck--and aren't sure how to best partner with Copilot while creating apps.   Whether you're looking for the best prompts or just want to know about responsible AI use, visit Copilot Cookbook for regular updates you can rely on--while also serving up some of your greatest tips and tricks for the Community. Check Out the new Copilot Cookbook for Power Apps today: Copilot Cookbook - Power Platform Community.  We can't wait to see what you "cook" up!