How to convert hours into minutes

T

Tim Ferguson

How would I convert total hours into minutes?
For exampl: 2:10 into 130 minutes

Public Function ShortTimeToMinutes(timeString As String) As Integer

Dim v As Variant

v = Split(timeString, ":")
If UBound(v, 1) <> 1 Then
Err.Raise 5, , "Bad short time format"

ElseIf Not IsNumeric(v(0)) Or Not IsNumeric(v(1)) Then
Err.Raise 5, , "Bad short time format"

Else
ShortTimeToMinutes = CInt(v(0)) * 60 + v(1)

End If

End Function


Hope that helps


Tim F
 
J

Jeff Boyce

Where? In a query?

Hours * 60 = minutes.

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
J

John W. Vinson

How would I convert total hours into minutes?
For exampl: 2:10 into 130 minutes

How are you getting the 2:10?

Note that Access Date/Time values are NOT appropriate for storing
durations; a Date/Time value is actually stored as a Double Float
count of days and fractions of a day since midnight, December 30,
1899. As such, a duration over 24 hours will NOT show as (e.g.) 28:15,
but as #31-Dec-1899 04:15:00#. If you're storing durations at
one-minute granularity, it's usually best to store them in a Long
Integer number field, and use an expression like

[Duration] \ 60 & Format([Duration] MOD 60, ":00")

to display hours and minutes.

John W. Vinson [MVP]
 

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