I’m asking because it seems you can compare a date object’s date fine, but assigning them to each other assigns the date objects date, in addition to the reference to the date object. So is it safe? Or should one always compare dates using .TotalSeconds?
I ran into this …
[code] while not rs.eof
lastUpdate_s = rs.idxField(1).stringValue
if lastUpdate_s <> "" then
lastUpdate_d.SqlDateTime = lastUpdate_s // On the second iteration of the loop, this changes the date stored in d1 to lastUpdate_d date here. So the next line performs the compare using the wrong date.
if lastUpdate_d < d1 then d1 = lastUpdate_d
end if
rs.moveNext
wend[/code]
[code] while not rs.eof
lastUpdate_s = rs.idxField(1).stringValue
if lastUpdate_s <> "" then
lastUpdate_d.SqlDateTime = lastUpdate_s
if lastUpdate_d < d1 then d1.SQLDateTime = lastUpdate_d.SQLDateTime // If assign using .SQLDateTime, then on the second iteration of the loop, the above line won't change d1 to lastUpdate_d.
end if
rs.moveNext
wend[/code]
if d1 = d2 then
// same date
end if
[/code]
what gets compared is the total seconds value
So you literally check to see IF thee represent the same point in time
HOWEVER, when you do
[code] dim d1 as new date
dim d2 as new date
d1 = d2
[/code]
This does NOT copy data from one to the other
What it does do is make it so you have 2 references to the same object