Tankerman,
I am well familiar with what you are trying to accomplish, albeit in
ocean-going vessels the approach is different. My suggesttion is to do
the
caluclation in lines of:
Delay=EndDelay-StartDelay (use your field names) and use the function
below
to dipsplay it correctly:
+++++
Private Function FormatTime( _
tmNumber As Double, _
Optional strSeparator As String = ":", _
Optional inclSuffix As Boolean = False, _
Optional dispDays As Boolean = False) As String
'-------------------------
'Return a string with time format, allowing more then
'31 days or more than 24 hours
'****Does NOT allow for Seconds
'Written by JK
'Plaese Feel free to use with or without acknowledgment
'but it would be appreciated if you acknowlege the Newsgroup
'---------------------------------------
'Parameters:
'Examples are based on 2 days 15 hours 30 minutes
'tmNumber: Time Number, 1= 1 day, example=2.645833333
'strSparator: Time saparator eg ":" eg 02:15:30
'InclSuffix: Add suffix to time e.g.
' 02d:15h:30m (no option to change suffix)
'displayDays: If Fales, dispaly day in hours, eg.
' 02d:15h:30m = 63h:30m
Dim tmpNum As Double, _
tmpDD As Long, _
tmpHH As Long, _
tmpMM As Long, _
strDD As String, _
strHH As String, _
strMM As String, _
isNeg As Boolean
'tmpNum: Temprary storage
'tmp/StrDD: How days are displayed, if at all
'tmp/strHH: Number of hours to display
' depending on dispalyDays
'tmp/strMM: Number of Minutes
'isNeg: Negtive time indicator
tmpNum = tmNumber
isNeg = IIf(tmpNum < 0, True, False)
tmpNum = Abs(tmpNum)
tmpDD = Int(tmpNum)
tmpNum = (tmpNum - Int(tmpNum)) * 24
tmpHH = Int(tmpNum)
tmpHH = tmpHH + IIf(dispDays, 0, tmpDD * 24)
tmpNum = (tmpNum - Int(tmpNum)) * 60
tmpMM = Round(tmpNum, 0)
If tmpMM = 60 Then
tmpMM = 0
tmpHH = tmpHH + 1
End If
If dispDays Then
strDD = IIf(tmpDD <= 9, "0", "") _
& Trim(Str(tmpDD)) _
& IIf(inclSuffix, "d", "") _
& strSeparator
Else
strDD = ""
End If
strHH = IIf(tmpHH <= 9, "0", "") _
& Trim(Str(tmpHH)) _
& IIf(inclSuffix, "h", "") _
& strSeparator
strMM = IIf(tmpMM <= 9, "0", "") _
& Trim(Str(tmpMM)) _
& IIf(inclSuffix, "m", "")
FormatTime = IIf(isNeg, "-", " ") _
& strDD & strHH & strMM
End Function
++++
I hple this is of help
Regards
Jacob
tankerman said:
Larry, Yes I am using hours and minutes and it seems to always come
back
with
the correct hours and minutes between the two fields. Here is the VB I
use
Public Function TimeDuration(dblDuration As Double) As String
Const HOURSINDAY = 24
Dim strDays As String
Dim strMinutes As String
'get number of days
strDays = Int(dblDuration) * HOURSINDAY + _
Format(dblDuration, "h")
' get minutes
strMinutes = Format(dblDuration, ":nn")
TimeDuration = strDays & strMinutes
End Function
JK, Yes I am trying to figure the delays we have in pumping or loading
barges at different facilities, delays are chargable to a facility or
to
the
barge dependiing on reason for the delay and length of the delay. In my
database the reason for the delays are entered with the dates and times
in
seperate fields so we can accurately track the hours and minutes of
each
delay as well as the total of the delays because we are having some
facilities shutting us down 2 or 3 different times for a various
reason.
We
are trying to track the reasons as well to see if there is a patteren
to
the
delays.
JK" wrote:
Tankerman,
Going by your nick in conjunction with the question, are you talking
about
oil tankers (as in shipping) demurrage calculation?
If so, I can help, otherwise please ignore my replay
Regards
Jacob
In my database I have 2 fields "FirstDelayEnd" and "FirstDelayStart"
these
are date and time fields I have a third field called
"FirstDelayTotal"
with
this formula in the control source
=TimeDuration([FirstDelayEnd]-[FirstDelayStart]) (I have VB to get
the
correct time format) and it works great. I have the same for the
"Second"
and
"Third" delays and they work fine. But when I
=Sum(First+Second+Third)
I
get
1:202:253:10 (First was 1:20, Second was 2:25 and Third was 3:10)
instead
of
5:55 what am I doing wrong. I'm am new at all this so I don't know
much.