Calculate dates to hours

Huey3

New member
Local time
Today, 10:47
Joined
Mar 5, 2013
Messages
3
Hi all,
I need to calulate from dates and hours to hours and tenth of a minute. For example an aircraft is placed on hold on 1 Feb 13, 0900hrs until 15 Feb 13, 1300hrs. I need to calculate the total time on hold in hours and tenths of a minute. I appriciate any assistance you can give me. Thank you in advance.
 
Thank you,
I will let you know how it works.
 
How to convert decimal time from Date/Time calculation
StartTime and EndTime are Date/Time types

Dim ElpsdTime, EintMin, EintSec, EintTSec, As Double
Dim EintHr As Single
Dim intHr, intMin As Integer

ElpsdTime = CDbl(![EndTime] - ![StartTime])

intHr = Hour(ElpsdTime) 'Rounded Hours Function
txtHR = Str(intHr) 'String Hours ++++++++++++++++++++++
'++++++++++++++++++++++Hours
EintHR = ElpsdTime * 24 'Convert decimal to hours
'++++++++++++++++Minutes
intMin = Minute(ElpsdTime) 'Rounded Minutes function
txtMin = Str(intMin)
txtMin = LTrim(txtMin)
strLEN = Len(txtMin)
If strLEN = 1 Then
txtMin = (":0" + txtMin)
Else
txtMin = (":" + txtMin) 'String Minutes +++++++++++++++++
End If
'++++++++++++++++++++++Seconds
EintMin = (EintHR - intHr) 'Subtract Hours to get decimal minutes
EintMin = (EintMin * 60) 'Convert decimal minutes to minutes
EintSec = (EintMin) - intMin 'Subtract minutes to get Seconds
If EintSec <= 0 Then
EintSec = 0
EintTSec = 0
txtSec = ":00"
Else
EintSec = (EintSec * 60) ' Convert decimal to seconds
EintTSec = EintSec 'Set Tenths
strPos = InStr(1, (EintSec), ".") 'Find decimal point
EintSec = Left(EintSec, (strPos - 1)) 'Set seconds value
txtSec = Str(EintSec) 'String Seconds +++++++++++++++++++++++
txtSec = LTrim(txtSec)
strLEN = Len(txtSec)
If strLEN = 1 Then
txtSec = (":0" + txtSec)
Else
txtSec = (":" + txtSec)
End If
End If
'+++++++++++++++++++Tenths of seconds
If EintTSec > 0 Then
EintTSec = EintTSec - EintSec
strPos = InStr(1, (EintTSec), ".")
txtTSec = LTrim(Str((Right(txtTSec, 2))))
End If
 
Last edited:

Users who are viewing this thread

Back
Top Bottom