Convert minutes to hours and mins

  • Thread starter Thread starter Danie
  • Start date Start date
D

Danie

I have used a DateDiff and have the result in mins. How do I convert it to
hrs and mins.

Thanks,
Danie
 
Hi Danie,
here is an example for 567 minutes

Private Sub Test1()
Dim strHoursAndMins As String

strHoursAndMins = 567 \ 60 & Format$(567 Mod 60, "\:00")
Debug.Print strHoursAndMins

End Sub

Here's an example to use in a query.
The table has a field called MinsWorked and a field called HrsWorked.

TotHrsMins: (Sum(Nz([MinsWorked],0))+Sum(Nz([HrsWorked],0))*60)\60 &
Format(Sum(Nz([MinsWorked],0)) Mod 60,"\:00")



Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia
 
Thank you so much for your help.

Jeanette Cunningham said:
Hi Danie,
here is an example for 567 minutes

Private Sub Test1()
Dim strHoursAndMins As String

strHoursAndMins = 567 \ 60 & Format$(567 Mod 60, "\:00")
Debug.Print strHoursAndMins

End Sub

Here's an example to use in a query.
The table has a field called MinsWorked and a field called HrsWorked.

TotHrsMins: (Sum(Nz([MinsWorked],0))+Sum(Nz([HrsWorked],0))*60)\60 &
Format(Sum(Nz([MinsWorked],0)) Mod 60,"\:00")



Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia

Danie said:
I have used a DateDiff and have the result in mins. How do I convert it to
hrs and mins.

Thanks,
Danie
 
Not knowing the overall application, an alternative would be to simply
subtract the two date/times (assuming you haven't done anything to cut off
the decimal part (time part). Then you can format the answer as desired using
Format(). Seems a lot simpler if it works...
 
Often in an app, user wants to enter elapsed time, so the field is not a
date/time data type and DateDiff with format is not a solution.


Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia
 
Back
Top