I want to calculate the number of hours & minutes between two different dates and times (i.e 05/04/03 13:00 and 06/04/03 14:10 = 25:10 (hours).
Can anyone advise how?
You could write your own function for this in VBA, or just do it in the query.
VBA:
Code:
Public Function HoursMins(dt1 as Date, dt2 as Date) as String
Dim lngMins as Long
lngMins = DateDiff("n",dt1,dt2)
HoursMins = (lngMins \ 60) & ":" & (lngMins Mod 60)
End Function
Then you could use the above function in a query:
fldHours: HoursMins([fldDate1],[fldDate2])
There are other ways you can do this also - hopefully this give you a start. Note that if dt1 is later (more recent) than dt2, you'll get a negative number.
We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel
Which adblocker are you using?
Disable AdBlock
Follow these easy steps to disable AdBlock
1)Click on the icon in the browser’s toolbar. 2)Click on the icon in the browser’s toolbar. 2)Click on the "Pause on this site" option.
Go back
Disable AdBlock Plus
Follow these easy steps to disable AdBlock Plus
1)Click on the icon in the browser’s toolbar. 2)Click on the toggle to disable it for "mrexcel.com".
Go back
Disable uBlock Origin
Follow these easy steps to disable uBlock Origin
1)Click on the icon in the browser’s toolbar. 2)Click on the "Power" button. 3)Click on the "Refresh" button.
Go back
Disable uBlock
Follow these easy steps to disable uBlock
1)Click on the icon in the browser’s toolbar. 2)Click on the "Power" button. 3)Click on the "Refresh" button.