Hi All,
How can I compare 2 dates?
I would like to compare a date/time field with the NotesDateTime.
Here is my coding:
Dim dateTime As New NotesDateTime( “Today” )
Call dateTime.AdjustMonth( -60 )
If doc1.DateA(0)<= dateTime.DateOnly Then
......
End If
But it failed to compare, any value will just go into the condition, what is wrong?
Thanks.
Subject: Date Comparison
The error is because the field is not a NotesDateTime, but a DateTime Variant. You must declare and initialize another NotesDateTime like this:Dim twoMonthsAgo As New NotesDateTime(“Today”)
Call twoMonthsAgo.adjustMonth(-60)
Dim myDate As New NotesDateTime(“Today”)
myDate.lsLocalTime = doc1.getItemValue(“DateA”)(0)
If myDate.dateOnly <= twoMonthsAgo.dateOnly Then End If
johan@kanngard.net
http://dev.kanngard.net
Subject: RE: Date Comparison
What is myDate.IsLocalTime?
I can’t find IsLocalTime from help index. And it gave the error that “Must be from date property”.
Subject: Date Comparison
Sorry, my mistake, should be MyDate.LocalTime.
But it still failed to compare. When I debug, even though myDate is bigger than dateTime, but it still go into the condition.
Subject: RE: Date Comparison
My bad, you have to use myDate.timeDifference(twoMonthsAgo)…
johan@kanngard.net
http://dev.kanngard.net
Subject: RE: Date Comparison
Actually, you should can do a comparison using
If myDate.lsLocalTime <= twoMonthsAgo.lsLocalTime Then …
Shelyn - make sure you are looking for LSLocaltime, not ISLocalTime in the help (a bit hard to tell the difference on the web with a sans serif font )