date validation?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Null

    #1

    date validation?

    How to write an IsDate function that actually checks for a particular date
    format?

    Using try-catch on Convert.ToDateT ime(sDate) doesn't catch invalid entry
    (i.e. 5/2000).....I want the dates to be input as mm/dd/yyyy OR m/d/yyyy OR
    m/d/yy (etc.)....

    Any thoughts?


  • Alvin Bruney

    #2
    Re: date validation?

    a regex would come in handy here http://regexlib.com/
    or do a cheesy
    System.DateTime myDateTime = DateTime.Parse( testString);

    and check myDateTime for validity. I prefer regex though

    "Null" <farthumstill@h otmail.com> wrote in message
    news:uX9w69LVDH A.1316@TK2MSFTN GP12.phx.gbl...[color=blue]
    > How to write an IsDate function that actually checks for a particular date
    > format?
    >
    > Using try-catch on Convert.ToDateT ime(sDate) doesn't catch invalid entry
    > (i.e. 5/2000).....I want the dates to be input as mm/dd/yyyy OR m/d/yyyy[/color]
    OR[color=blue]
    > m/d/yy (etc.)....
    >
    > Any thoughts?
    >
    >[/color]


    Comment

    Working...