Date format diffenerce serve and client

dear all,

i have an agent which should compare if two fields in a doc contain the same date:

field ‘Lieferdatum’ is type date and

field ‘Lieferdatum_1’ is type text (multivalue)

i want to check if the date in 'field ‘Lieferdatum’ is already in the textfield ‘Lieferdatum_1’ (this field keeps a ‘history’ of date-changes so it contains multible dates as a text list). for this i get the first value in this array (Lieferdatum(0), convert it to a date/time value and compare it with the value of ‘Lieferdatum’:

the following agent-script runs perfectly when startet on my client, but when running on the server, the line with Cdat gives an type mismatch error.

Dim lt As Variant

Dim lt_1 As Variant

Dim doc as Notesdocument

Set doc …

…

Let lt =“”

Let lt_1 =“”

Let flagtext=“”

lt = doc.Lieferdatum(0) 'retrieving a date

lt_1=Cdat(doc.Lieferdatum_1(0)) 'converting the datestring to a datevalue → error type mismatch only when run on server, not on client.

from the properties box:

Lieferdatum’s format is like 06.12.2006 Date/Time

Lieferdatum_1’s format is like “06.12.06” TextList

on my client the date separator is set to ‘-’ so when i print the date it shows me “06-12-06”

I also tried the same with Datevalue instead CDat which gives me an error message: Illegal function call.

please help!

Subject: date format diffenerce serve and client

Unfortunatley you’re mixing types.

Lieferdatum_1 - I assume you don’t “force” the format of the date but instead use @text() or something to convert the date to a text value.

So if I’ve got my date format set to 2006-/-DD-/-MM (because I could) your code is going to fail on the server.

Your two options is to change Lieferdatum_1 to a Date field with multiple values. Or FORCE the format of the date in the code…

yr := @right(@text(@year(@now));2) - since you like 2 digit years

mn := @right(“0” + @text(@month(@now));2) - 2 digit month

dy := @right(“0” + @text(@day(@now));2) - 2 digit day.

They write out:

field Lieferdatum_1 := (yr+ “.” + mn + “.” + dy) : ‘Lieferdatum_1’

Hope that helps.

(Go with a multi-value date field!)

Subject: RE: date format diffenerce serve and client

Thanks Stephen,

you are right, as i do not force a fixed format (i indeed use @text to convert from date to text) and anyway a fixed dateformat will always be a unsure matter, i’m going to use a multivalue datefield. therfore i’m going to use a multivlaued date field.

… and again i need help:

looking in designers help all list operations (formula) work wiht text but not with date/time, how can i add date-values to a multivalue date field, and how can i check for matching values?

maybe i can’t see it because its already 10:15 pm …

thanks for any help

jakob

Subject: RE: date format diffenerce serve and client

It appears you’re your correct using @ functions means working with text or numbers. So you’d have to fall back on LotusScript to work with dates.

Here is a little piece of code I wrote in the QueryClose. Where A is the single Date and B is the datelist that is added to if the date isn’t previously in the list.

Sub Queryclose(Source As Notesuidocument, Continue As Variant)

. .

. . Dim doc As NotesDocument

. .

. . Dim datelist() As Variant

. . Dim c As Integer. .

. . Dim matchfound As Boolean

. .

. . matchfound = False

. . Set doc = source.Document

. .

. . If Trim(doc.B(0)) = “” Then

. . . . doc.B = doc.A

. . Else

. . . . size = Ubound(doc.B). .

. . . . Redim datelist(size)

. . . .

. . . . For c=0 To size

. . . . . . If doc.A(0) = doc.B(c) Then

. . . . . . matchfound = True

. . . . . . End If

. . . . . . datelist(c) = doc.B(c)

. . . . Next

. . . .

. . . . If Not matchfound Then

. . . . . . size = size + 1

. . . . . . Redim Preserve datelist(size)

. . . . . . datelist(size) = doc.A(0)

. . . . . . doc.B = datelist

. . . . . . Call doc.Save(False,False)

. . . . End If

. . . .

. . End If

End Sub

Subject: date format diffenerce serve and client

The problem could be because the date formate in the XP Registries is in the US MM/DD/YY and the client is in a different format. Here is a link to a FAQ that we get regularly. Hope it helps:

http://www.wfs.com/workweb/DLATrouble.nsf/740ef94ac62ac8a685256324006d4a58/f25d07863021ddff87256d27005bd3ae!OpenDocument

Subject: date format diffenerce serve and client

Dates and date formatting/internationalization is such an awful problem in Notes that we have been forced to introduce a development policy banning the use of CDat.

The only safe way to compare dates is to convert them to NotesDateTime objects and use the TimeDifference[Double] methods. We have databases that replicate across time zone and international boundaries and we have had nothing but problems with dates because of the CDat function and the fact that the Canadian date format is mm/dd/yyyy and the preferred American one is dd/mm/yyyy. Thow in the 3 hour time difference between PST and EST you get the added bonus of dates changing by one day when they are entered in the East and processed by an agent in the West or vice-versa. It is enough to drive you nuts.

With respect to your specific problem, I would do it like this:

Dim testdate as NotesDateTime

Dim testdate2 as NotesDateTime

Dim datearchive as NotesItem

Dim ws as New NotesUIWorkspace

Dim currdoc as NotesDocument

Dim x as Integer

set currdoc = ws.CurrentDocument.Document

set datearchive = currdoc.GetFirstItem(“Lieferdatum_1”)

set testdate = new NotesDateTime(currdoc.Lieferdatum(0))

For x = 0 to ubound(datearchive.Values)

set testdate2 = new NotesDateTime(datearchive.Values(x))

’ We use 50000ms as a basis for comparison - there are 86,4000 ms in a day

If testdate2.TimeDifferenceDouble(testdate) < 50000 Then

msgbox "The date is the same"

End If

Next

HTH

Subject: RE: date format diffenerce serve and client

:slight_smile: Some of us (Canadians) prefer yyyy-mm-dd (it sorts nicely) - Hint, me, me, me…

Must be the french influence on the date as I would say it’s December 7th, 2006 (thus mm/dd/yyyy) not 7th of December, 2006 (dd/mm/yyyy)

Zed! :slight_smile: