DateNumber and db.search issue

On a lotus database, I have a script that performes a db.search. But one of my user has an error.The script is like this :

Dim vStartDateSearch As Variant

vStartDateSearch = Datenumber(nYear, nMonth,1)

formula$ = “Form = ““Appointment”””

formula$ = formula$ + " & CalendarDateTime >=[“+vStartDateSearch+”]"

Set coll = db.search (formula$, Nothing, 0)

For one user in Asia (unfortunately one of the most important ;-( ), the error is :

Formula Error (Form = “Appointment” & CalendarDateTime >=[01-Jan-06]")

For the other users, the formula is equal to : (Form = “Appointment” & CalendarDateTime >=[01/01/06]")

I think that the search doesn’t like the format Month in letter instead of number !!

1/ I would like to know which local setting can format the date like this “dd-MMM-yy”, because I check his regional options (set to English (United States)) and the field short date is formatted like taht :“dd/MM/YY”.

I want first to reproduce the issue in order to solve it.

I try to change my regional options and I try to not use OS settings but Notes settings. Nothing.

2/ I wonder why the error raises because DateNumber creates a date object (through the variant object) and not a string.

Thanks for any help

Cathy

Subject: RE: DateNumber and db.search issue

Intresting !!! , the common local setting for date and time is :- for windows , > start control planel > regional settings >> time >> date , change to format DD/MM/YY. if these settings are ok , still ,error, I am not sure ,

thought to give a try …

Best Luck

Hari

Subject: RE: DateNumber and db.search issue

You’re using the default conversion of date to string, which depends on the user’s settings. You might want to look at the Format function. You might also consider using a NotesDateTime object, which has its own date-to-text rules. Also, there’s the @Date function, which lets you provide the date in a format completely independent of the user’s preferences. I.e.:

formula$ = {Form = “Appointment” & CalendarDateTime >= @Date(} & nYear & {; } & nMonth & {;1)}

Note, however, that this is also the kind of search that’s much faster using FTSearch.

Subject: RE: DateNumber and db.search issue

Tx Andre for the response.But the return value of DateNumber is a date (variant) object and not a string. That’s the reason why I don’t really understand.

But anyway, with @Date it works perfectly. Tx again for the clue (it’s the second time that you help me)

Cathy

Subject: RE: DateNumber and db.search issue

Sure, Datenumber returns a date/time variant. But if you take that variant and concatenate it to a string, the result is not some weird hybrid value that’s part string, part date/time. A string plus some other value gives a string, so the date/time is converted to characters and those are added to the string. The Format function would give you control over how that date-to-string conversion is done – if you don’t use Format, a default formatting is used.

Subject: RE: DateNumber and db.search issue

ok Andre, Thanks, I have understood now.Cathy