Date Verfication

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

    #1

    Date Verfication

    Is there a good C# function to verify if a date is valid? Right now I am
    casting a date that is in string form (Convert.ToDate Time(dateString )) and
    catching an exception. This seems sort of lame.


    ???


  • Fred Mellender

    #2
    Re: Date Verfication

    Well, you could use DateTime.Parse( String); but you will still have to catch
    an exception (FormatExceptio n).

    "S" <spamaway@hotma il.com> wrote in message
    news:%23sqquNvo DHA.2584@TK2MSF TNGP09.phx.gbl. ..[color=blue]
    > Is there a good C# function to verify if a date is valid? Right now I am
    > casting a date that is in string form (Convert.ToDate Time(dateString )) and
    > catching an exception. This seems sort of lame.
    >
    >
    > ???
    >
    >[/color]


    Comment

    • alex

      #3
      Re: Date Verfication

      You can use RegEx to test for valid date patter. Check this site for some
      regex patters: http://www.regexlib.com/

      "S" <spamaway@hotma il.com> wrote in message
      news:#sqquNvoDH A.2584@TK2MSFTN GP09.phx.gbl...[color=blue]
      > Is there a good C# function to verify if a date is valid? Right now I am
      > casting a date that is in string form (Convert.ToDate Time(dateString )) and
      > catching an exception. This seems sort of lame.
      >
      >
      > ???
      >
      >[/color]


      Comment

      Working...