I believe you can compare dates directly, using standard comparison operators.
Letâs say you have
Code:
Dim tmpDate As Date
and your array, arr(), is loaded with simple dates (and is declared as an array of Dates). Let's further assume the number of elements is not more than an Integer can ID (a pretty safe assumption). Then, to ID the oldest:
Code:
Dim i As Integer
Dim OldestID As Integer
Dim tmpDate As Date
i = LBound(arr)
OldestID = i ' If no older dateâs found, youâll end up with this.
For i = LBound(arr) + 1 To UBound(arr)
If arr(i) > arr(OldestID) Then
OldestID = i
End If
Next i
Now Oldest ID is pointing to the oldest date, if there were no duplicates, or the first of the duplicates if there are any.
Does that help?