Problems with date

Hi,

I have a issue to solve: the date (today) in the date field of my documents are saved as yesterday.

I have a form that supports several different entries, that is, date, text, numbers and so on.

This form does not become a document. Through lotusScript I wrote a code that save those data in another form, whose has the same field (as itens, of course).

So, my views show select documents based in the last above saved form.

Looking inside the properties of the document, looking for that date field, there is the correct date (today).

Trying a workaround, I intended to write another code to rewrite dates to that date field, but it confirms the wrong date (yesterday) not the correct one.

Anyone could help me?

Thanks.

Subject: Problems with date

Thank you, Rameez Latheef and thank you Andre Guirard:

I wrote the code, following the tip of Girard:

Dim dt As New NotesDateTime( uidoc.fieldgetText("AliTxtDaD") )

doc.DefTxtDaD= Cdat(dt.DateOnly)

            call doc.save(true,false)

I think now it will work fine.

Subject: RE: Problems with date

Sorry, that’s still exactly what you don’t want to do. CDat returns a date/time variant, so if you assign that to a field you still get the 12:00:00 AM. You have to do something like this:

Dim dt As NotesDateTime

dim docCur as notesdocument

set docCur = uidoc.document

set dt = doc.GetFirstItem(“AliTxtDaD”).DateTimeValue

docOther.ReplaceItemValue “DefTxtDaD”, dt

call docOther.save(true,false)

I also draw your attention to the CopyItemToDocument method.

Subject: RE: Problems with date

Dear Guirard,

thank you again.

I modified your suggestion to

Dim dt as NotesDateTime(“”)

Dim docCur As notesdocument

Set docCur = uidoc.document

Set dt = docCur.GetFirstItem("AliTxtDaD").DateTimeValue

docCur.ReplaceItemValue "DefTxtDaD", dt

What do you think about?

Subject: RE: Problems with date

I think it won’t compile, but once you fix the compiler error you will be OK.

For the sake of others who might have the same question, please don’t post the solution until you’ve tried it.

Subject: RE: Problems with date

My code ran ok, but the field ‘DefTxtDaD’ became null.

I tried to input the object ‘dt’ with uidoc.FieldGetText(“AliTxtDaD”) as a parameter to ‘feed’ dt, but this not also work.

Subject: Problems with date

I guess Notes is converting the date to Local time zone and this is causing the difference. Post the code and maybe we can dig further

Subject: RE: Problems with date

When you store a date with LotusScript, if you don’t want to also store a time of day, you must use the NotesDateTime class with SetAnyTime method. If you just do something like:

doc.Fieldname = Today

then it’s really storing today at 12:00:00 AM, which is yesterday in some timezones. The date/time variant doesn’t distinguish between “date only” and midnight.