Convert minutes to hours and mins

D

Danie

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

Thanks,
Danie
 
J

Jeanette Cunningham

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
 
D

Danie

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
 
F

Frank H

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

Jeanette Cunningham

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top