NotesDateTime and current date

Hello All,

I am trying to make the snippet of code below check validation under certain conditions. It works for all except this condition:

gDoc.GetItemValue(“estFilingDateCal”)(0) < gdoc.GetItemValue(“dateTime.LSLocalTime”)(0) Then

This condition should also show the validation prompt. Estimate Filing Date cannot be in the past

It does not here is a snippet of the code to control the conditions and validations.

’ 'jw start 07/04added code below to validate date fields - Estimate filing date cannot be in the past

Dim dateTime As New NotesDateTime( "" )

Set DateTime = New NotesDateTime(Now()) 

'dateTime.LSLocalTime = Now



If gDoc.getItemValue("estFilingDateCal")(0) < gDoc.getItemValue("SECAvailableEstCal")(0) Or _

gDoc.getitemValue("estFilingDateCal")(0) < gDoc.getItemValue("SECAvailableActCal")(0) Or _ 

gDoc.getItemValue("estFilingDateCal")(0) < gDoc.getItemValue("SECCommentEstCal")(0)  Or _ 

gDoc.getItemValue("estFilingDateCal")(0) <  gDoc.getItemValue("SECCommentActCal")(0) Or _   

gDoc.GetItemValue("estFilingDateCal")(0) < gdoc.GetItemValue("dateTime.LSLocalTime")(0) Then	

	

	IntAnswer= Messagebox("Is this a post filing review?",	MB_YESNO + MB_ICONQUESTION, "Post Filing Review")

	If IntAnswer = IDNO Then

		gdoc.estFilingDateCal = ""			

		intErrorCount=intErrorCount+1

		Redim Preserve aryStrErrors(intErrorCount)

		aryStrErrors(intErrorCount)=|Estimate Filing Date cannot be in the past.|

		strFieldGoto = "estFilingDateCal" 			

	End If 		

'End If

Your help and feedback is greatly appreciated

Subject: NotesDateTime and current date

I’m guessing that you’re probably getting a type mismatch error. I think you probably intended to compare the “estFilingDateCal” date/time value to the current date/time value. This could be done as follows:

Dim dateTime As NotesDateTime

Set dateTime = New NotesDateTime(Now) '// fyi, this is the LOCAL machine's time



If gDoc.getItemValue("estFilingDateCal")(0) < gDoc.getItemValue("SECAvailableEstCal")(0) Or _

gDoc.getitemValue("estFilingDateCal")(0) < gDoc.getItemValue("SECAvailableActCal")(0) Or _ 

gDoc.getItemValue("estFilingDateCal")(0) < gDoc.getItemValue("SECCommentEstCal")(0) Or _ 

gDoc.getItemValue("estFilingDateCal")(0) <  gDoc.getItemValue("SECCommentActCal")(0) Or _   

gDoc.GetItemValue("estFilingDateCal")(0) < dateTime.LSLocalTime Then

I would also suggest getting the date/time value of the “estFilingDateCal” field into a variable as opposed to accessing it in the document five times.

dim ndtNow as NotesDateTime

dim ndtEstFiling as NotesDateTime

dim varTmp as Variant



set ndtNow = New NotesDateTime(Now) '// fyi, this is the LOCAL machine's time

set ndtEstFiling = gDoc.GetItemValueDateTimeArray("estFilingDateCal")(0)

varTmp = ndtEstFiling.LSLocalTime



If varTmp < gDoc.getItemValue("SECAvailableEstCal")(0) Or _

varTmp < gDoc.getItemValue("SECAvailableActCal")(0) Or _ 

varTmp < gDoc.getItemValue("SECCommentEstCal")(0) Or _ 

varTmp <  gDoc.getItemValue("SECCommentActCal")(0) Or _   

varTmp < ndtNow.LSLocalTime Then

hth,

dgg

Subject: RE: NotesDateTime and current date

Try gDoc.GetItemValue(“estFilingDateCal”)(0) < Today.

BTW when you want to set a NotesDateTime to now, you can also use the SetNow method.

GetItemValue only works for fields (items) in the document. It failed in your case because dateTime.LSLocalTime is not the name of an item. Datetime is the name of a variable in your script – not at all the same thing. And you would not, in any case, be able to get a property of an item by using a “.” inside the string you pass to GetItemValue. E.g. doc.GetItemValue(“fieldname.IsReaders”) also will not work.