This is most likely due to floating point precission issues. Dates are stored as double precission floats, where the integer part is date and fractional part is time.
To test if arrPP(iPP_START,lPP_index)
is before dNextStartTime
it's probably best to use
If DateDiff("s",dNextStartTime,arrPP(iPP_START,lPP_index)) <= 0 Then
Note that DateDiff
returns possitive when the first date parameter is earlier than the second.
To demonstrate how two apparently equal dates may not be equal, try running this
Sub demo()
Dim d1 As Date, d2 As Date
d1 = #12/17/1986 12:19:33 PM#
d2 = #12/17/1986#
d2 = d2 + 12# / 24# ' Add 12 hour
d2 = d2 + 19# / 60# / 24# ' Add 19 minutes
d2 = d2 + 33# / 60# / 60# / 24# ' Add 33 seconds
Debug.Print d1; d2
Debug.Print d1 = d2
Debug.Print d1 - d2
End Sub
Immediate window output
17/12/1986 12:19:33 p.m. 17/12/1986 12:19:33 p.m.
False
3.63797880709171E-12