developerWorks  >  Lotus  >  Forums & community  >  Notes/Domino 8 Forum

Notes/Domino 8 Forum



Feedback Type Problem
Subject Function to compare dates
Product Area Designer Client
Technical Area Application development
Platform ALL
Release 8.0.2
Reproducible Always
Hey!

I need a little help.

There's a function to compare two dates in lotusscript?

Let me explain:

I have two text fields on a web application and I get this dates and make a comparation to run the agent. I know that compare two date- text strings are impossible, so I tried to make it with LSLocalTime.

But I got errors, a lot of them. Could you help me to resolve this pluzze?!

Thanks in advance.

Here is the code:

Use "WorkflowProcedures"
Sub Initialize

MsgBox "Agente MediaDia - Entrou no agente!"

On Error GoTo TrataError

Dim ses As New NotesSession
Dim db As NotesDatabase
Dim vis As NotesView
Dim col As NotesDocumentCollection
Dim doc As NotesDocument
Dim autor As Variant
Dim criacao As Variant
Dim dataHoje As String
Dim total As Long

dataHoje = Format(Now, "mm/dd/yyyy")

MsgBox "Data Hoje: " + CStr(datahoje)

Set Webdoc = ses.DocumentContext
Set db = ses.CurrentDatabase
Set vis = db.GetView("Autores")
Set col = db.Alldocuments
Set doc = col.Getfirstdocument()

'MsgBox "Autor do primeiro documento da colection: " + doc.Authors(0)

total = col.Count

total = 0

While not doc Is nothing

datadoc = doc.Created()

Dim data As New NotesDateTime(dataHoje)

Dim data1 As New NotesDateTime(datadoc)
MsgBox "Data Hoje: " + CStr(dataHoje) + " Data do Doc: " + CStr(datadoc)

If data.LSLocalTime = data1.LSLocalTime Then
'If datadoc = datahoje Then
MsgBox "**************************** Entrou no if *************************"

total = total + 1

End If

MsgBox " Contador: " & total

MsgBox "Data Criação dessa parada: " + CStr(Format(datadoc, "mm/dd/yyyy"))

Set doc = col.Getnextdocument(doc)
Wend



If total = 0 then

Print "<script language=""JavaScript"" type=""text/javascript"">"

'Print |var path = window.location.pathname.substring (0, window.location.pathname.toLowerCase().indexOf(".nsf") + 4);|

Print "alert('Não foram criados documentos de migrações hoje!" ".')";

MessageBox "Não foram criados documentos de migrações hoje!"




Else

Print "<script language=""JavaScript"" type=""text/javascript"">"

'Print |var path = window.location.pathname.substring(0, window.location.pathname.toLowerCase().indexOf(".nsf") + 4);|

Print "alert('Média de Migrações realizada durante o dia: " + CStr(total) + "" + ".')";

MessageBox "Média de Migrações realizada durante o dia: " & CStr(total)



End If

Print "</script>"

Exit sub
TrataError:

MsgBox "Erro: " + Error + Chr(10)+ " na Linha " + CStr(Erl) + Chr(10)+ "numero " + CStr(Err)

End Sub


Feedback number WEBB8UMPLM created by Gabrielle R Coutinho on 05/22/2013

Go back