Comparing two dates

Hi

Set ArchiveDate = New NotesDateTime(Format$(ArchivedDatevalue,“mm/dd/yyyy 08:00 AM/PM”))

	Msgbox ArchiveDate.DateOnly

	Set LimitDate  = New NotesDateTime(Format$("01/01/2007","mm/dd/yyyy 08:00 AM/PM"))

	Msgbox LimitDate.DateOnly

	'Before 01/01/2007 

	If Trim$(ArchiveDate.DateOnly) < LimitDate.DateOnly Then

xxxxxx

else

xxxxx end if

Here in the code while comparing the archive date=01/24/2004 that is less than 01/01/2007 which is the limit date. It is not going to the then part. Here the givenn condition is true. eventhough the control is not passed.

please help

thnks

Subject: Comparing two dates

Try to use the below code:

If cdat(ArchiveDate.DateOnly) < cdat(LimitDate.DateOnly)

Then

I hope it will be work.

Subject: Comparing two dates

.DateOnly returns a string, not a date. If you want to compare dates, you need to leave them as numbers, and not convert them to strings.

I don’t think you need to use NotesDate objects here - LotusScript date variants will do the job.

Dim ArchiveDate as Variant, LimitDate as Variant

ArchiveDate = Int(ArchivedDatevalue) ’ Taking just the integer part removes the time value

Msgbox ArchiveDate

LimitDate = DateNumber ( 2007 , 01 , 01)

Msgbox LimitDate

’ Before 01/01/2007

If ArchiveDate < LimitDate Then

Subject: Comparing two dates

use the TimeDifference of the NotesDateTime object…

This is straight from the help…

TimeDifference method

Finds the difference in seconds between one date-time and another.

Defined in

NotesDateTime

Syntax

difference& = notesDateTime.TimeDifference( notesDateTime )

Parameters

notesDateTime

NotesDateTime. Any date-time value.

Return value

difference&

Long. The date-time object invoking the TimeDifference method minus the notesDateTime object specified by the parameter, in seconds.