Weblog
9/2: IsDate("13/02/2007") = False ??
Strange one which I'm about to log on the Notes.Net forum. I hope it's not something too obvious.A couple of users have picked a date using the date picker in the Notes client. They chose 13th February 2007 in the date picker which put "13/02/2007" into the field. My program took a string representation of this date (taken from the UIDocument) and then used the IsDate() function prior to converting it to a Date Variant using the CDat() function.
However, the string failed the IsDate() check!
Fair enough I thought. They probably typed the date in and their PC is setup with an American format date or something. No, it's not that. The PC is setup correctly. To be sure, I made the program get the date format from the NotesInitialization class and put this into the error message. The users also swear that they used the date picker - and I believe them.
Here's an excerpt from the code:
and here's the resulting error message in the magnificent OpenLog database:
The error text says: "13/02/2007" is not a valid date. Date format should be "DD/MM/YYYY". Use the date picker if you didn't already.
Can any of you clever people tell me what I've done wrong? Surely this isn't a Notes bug?
Author: Rob Wills Categories: Domino

1. Robin Wills wrote:
FYI, forum post is here:
{ Link }
2. Robin Wills wrote:
I have basically decided not to use CDat() or IsDate() on strings PERIOD
When the same function works differently for different users it makes applications hard to test.
I used the Document property of the NotesUIDocument (which I should have done in the first place) and all is now well.
A lesson learnt.
3. Martin wrote:
Are you sure, that you write month in two place? What about 13/2/2007?
BTW: Why isn't it possible to write comments on this page - { Link } ?
4. Robin Wills wrote:
Thanks Martin for your comment.
It is hard for me to try this because I never had the problem myself. I solved the problem by using the Document property of the NotesUIDocument and getting the date directly from there. I didn't need to convert the string to a date so it is a better method to use.
As for why comments were not working, I wasn't aware that it wasn't working! Now that I know, I will check it out! Thanks.
5. Wild Bill wrote:
Yeah - I;d go along with anytime you see dates being translated from strings - expect trouble. Perhaps not today. Perhaps not tomorrow. But soon...
;-)
---* Bill