cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Ian-S
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"
))

 

MS_Help.JPG

 

Thank you in advance!

1 ACCEPTED SOLUTION

Accepted Solutions

Hi @Ian-S :

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

Please try this formula:

 

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

 

I think this link will help you a lot:

https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/functions/function-dateadd-datediff

Best Regards,

Bof

View solution in original post

4 REPLIES 4
cds
Impactful Individual
Impactful Individual

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

this will give you min..

 

formula obvio not complete but you get the idea

Ian-S
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! 

Hi @Ian-S :

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

Please try this formula:

 

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

 

I think this link will help you a lot:

https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/functions/function-dateadd-datediff

Best Regards,

Bof

Michael_Dav
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

Helpful resources

Top Solution Authors
Top Kudoed Authors
Users online (4,019)