Link to home
Start Free TrialLog in
Avatar of danpino
danpino

asked on

Convert 0,90 into 1 hour 30 min in MS ACCESS

Hi, I need to convert 0,90 into 1 hour 30 min or
1,90 to 2 hour 30 min.
Avatar of GrahamSkan
GrahamSkan
Flag of United Kingdom of Great Britain and Northern Ireland image

With VBA:

Sub CallStringToTime()
    Dim strTimeString As String
    strTimeString = "1,90"
    MsgBox StringToTime(strTimeString)
End Sub

Function StringToTime(strTimeString As String) As Date
    Dim strTimeParts() As String
    
    strTimeParts = Split(strTimeString, ",")
    StringToTime = TimeSerial(strTimeParts(0), strTimeParts(1), 0)
End Function

Open in new window

If your values are decimals, a one-liner will do:

datHours = TimeSerial(Int(t), (t - Int(t)) * 100, 0)

/gustav
ASKER CERTIFIED SOLUTION
Avatar of IrogSinta
IrogSinta
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I still believe 0,90 and 1,90 represent decimal numbers, thus should be treated as so.

/gustav
cactus_data,

Yes, that's interesting. But if the asker has continental settings so that 1,90 is the same as decimal 1.9 hours, then it would convert to 1 hour and 54 minutes, which is not what the asker expects.
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.