I am trying to compare a today’s date minus 1 year with the created date on a document using Script. The first problem I have is how to use script to strip out the time. One field has the time, the other doesn’t. Time is not relevant here. The second problem is that I keep getting a type mismatch. Here is my code:Sub Initialize
Dim Doc As NotesDocument
Dim NextDoc As NotesDocument
Dim strTemp As String
Dim RowCount As Long
Dim BadRowCount As Long
Dim strExportFile As String
Dim File As Integer
Dim BadFile As Integer
Dim Record As String
Dim tmpNow As Variant
Dim dateTime As New NotesDateTime(Today)
Call dateTime.AdjustMonth( -12 )
On Error Goto Error_Found
Set Session = New NotesSession
Set Db = Session.currentdatabase
’ YearAgo = Date(dateTime)
strExportFile = "c:\ProductDetailsExpanded.csv"
'Export the text file
File = Freefile()
Open strExportFile For Output As File
BadFile = Freefile()
Open "c:\BadFile.csv" For Output As BadFile
RowCount = 0
BadRowCount = 0
Set View = Db.GetView("(SupportRequestsByDate)")
Set Doc = view.GetFirstDocument
If Not Doc Is Nothing Then
Record = BuildLabel()
Print #File, Record
Print #BadFile, Record
End If
'Loop through the document collection and export them
While Not Doc Is Nothing
Dim DocDateTime As New NotesDateTime(doc.created)
If Year(DocDateTime) >= Year(dateTime) Then ****** error generated here
Record = ""
Set NextDoc = Doc.GetNextDocument(Doc)
Record = BuildLine(Doc)
RowCount = RowCount + 1
Print #File, Record
End If
Set Doc = NextDoc
Wend
Close File
Close BadFile
Continue:
strTemp = "Export Finished. " & RowCount & " Opportunities exported to " & strExportFile
Print strTemp
Messagebox strTemp
Exit Sub
Error_Found:
strTemp = "ERROR encountered in Initialize: " & Err() & " " & Error() & " at line " & Erl()
Print strTemp
Messagebox strTemp
Goto Continue
End Sub