Results 1 to 4 of 4
  1. #1
    5 Star Lounger
    Join Date
    Mar 2001
    Location
    New York, NY
    Posts
    922
    Thanks
    2
    Thanked 12 Times in 11 Posts

    IsDate (Word XP)

    I have several text controls in a user form that are meant to collect dates. (We don't want to use the Date Picker.) I have code at the BeforeUpdate event to verify the date, e.g. IsDate(txtInquiryDate.text), and if that proves FALSE, I set Cancel=True after display a message to the user that the date is invalid.

    This works... sort of. 4/31/07 is not valid because April has only 30 days. The result is not false if the user enters 30-4-07, apparently because that is a valid date with International style formatting (day/month/year). But when I format 30-4-07 ("mmmm d, yyyy"), the result is crazy. (April 7, 1930).

    Does IsDate not give good results, or is there something that I'm unaware of? I suppose the best asnwer is to use the Date Picker.

    Thanks,
    Richard Barrett

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: IsDate (Word XP)

    Apparently, Windows interprets 30-4-07 as yy/mm/dd. If you want to ban all ambiguity, one possibility is to use the Date and Time Picker, or the Calendar control. Another one is to use separate text boxes or combo boxes for day, month and year.

  3. #3
    5 Star Lounger
    Join Date
    Mar 2001
    Location
    New York, NY
    Posts
    922
    Thanks
    2
    Thanked 12 Times in 11 Posts

    Re: IsDate (Word XP)

    According to documentation, IsDate uses the local Windows settings for determining valid dates. This does not seem to be the case. We want to make it as easy as possible for the user to enter the dates (i.e. not force users to follow any standard), and then format the dates uniformly in the output document. I think this is not going to work unless we use the Date Picker.

    Thanks,
    Richard

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: IsDate (Word XP)

    Windows in general first tests whether a string is a valid date according to the local settings, but if it isn't, it also tests whether it is a valid date in other settings. For example, 30/04/2007 is interpreted as April 30, 2007 whether you are using mm/dd/yyyy format or dd/mm/yyyy format.
    Entering the year with only two digits is always dangerous, because it greatly increases the ambiguity: 01/02/03 could be January 2, 2003 or February 1, 2003, or February 3, 2001.
    A relatively safe format for entering dates is d-mmm-yyyy, e.g. 23-Apr-2007. This leaves no room for ambiguity. If you don't want to enforce such a format, the Date Picker or Calendar control, or separate controls for day, month and year are better.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •