IsDate("13/02/2007") = False

A couple of my users have been getting an error where basically a date that they have chosen using the standard Notes Client date picker then fails the IsDate() function.

Their PC is setup with a date format of DD/MM/YYYY and Isdate(“13/02/2007”) is returning False.

Full story is here:

http://www.inter-weavers.com/0/RobsBlog.nsf/dx/IsDate.htm

Can anyone explain this for me … PLEASE!

Thanks, Rob.

Subject: IsDate(“13/02/2007”) = False

I have never really understood this myself, but I do know how to get past it.

Ue the following code to check your field value…

Dim workspace As New NotesUIWorkspace

Dim uidoc As NotesUIDocument

Dim testdate As String

Set uidoc = workspace.CurrentDocument

testdate = uidoc.FieldGetText ( “dtField”)

Dim dt As New NotesDateTime(testdate)

If Not dt.IsValidDate Then

Messagebox "Please enter a new date." , , "Invalid date"

Call uidoc.GotoField ( "dtField")

End If

The NotesDateTime class constructor will accept a non date string and NOT throw an error, instead it sets the class date to a wildcard date and also sets the IsValidDate property to false.

Subject: RE: IsDate(“13/02/2007”) = False

I will check whether the IsValidDate property works differently to the IsDate() function. However, this doesn’t really solve my problem.

Surely, any date returned by the date picker should be a valid date? When I use the date picker and select 13th February 2007, the program recognises “13/02/2007” as a valid date. So why not for these other two users?

Unfortunately they are both in a remote office. Is this a clue? They are working on the same server as all the other users and it is working fine for the hundreds of other users.

Thanks Lawrence for your input. Rob.

Subject: RE: IsDate(“13/02/2007”) = False

All I know is that the NotesDateTime constructor is a lot more forgiving about date formatting.

I always tend to use NotesDateTime objects instead of LS datenumber values whenever possible because of problems just like the one you are experiencing.

Subject: RE: IsDate(“13/02/2007”) = False

You could do an IsdateDMY check before your standard IsDate check, and if IsDateDMY is true, convert your date to a MMDDYYY date before you do the regular Isdate check…

Subject: RE: IsDate(“13/02/2007”) = False

OK so what you are saying is that IsDate() uses the MDY format when it is passed a string. The confusing thing is that it returned True for most of our users and False for two of them. All users were setup with DMY format including the two it failed for.

Whilst I’m writing this, I’m thinking there may be a Notes.ini setting that deals with how dates are converted. One of my grey cells just tweaked from a few years back.

Anyhow, to fix this issue I decided to get the date directly from the Document property of the UIDocument which I should have done in the first place.

Thanks everyone and I’ll post further if I was right about a Notes.ini setting.

Rob

Subject: RE: IsDate(“13/02/2007”) = False

I will avoid using CDat() or IsDate() on strings in future PERIOD

There were Notes.INI settings in version 5 that affected date formats (overriding the operating system). These were no longer supported in Notes 6 onwards. However, certain code still honours them apparently. This might explain the inconsistencies that we have found between two users at one location and our other users.

Here’s an OLD article that explains the Notes.INI settings (dated 2001):

HTH, Rob