is there a way to verify that a date is in the right format?

Clovertech Forums Read Only Archives Cloverleaf Cloverleaf is there a way to verify that a date is in the right format?

  • Creator
    Topic
  • #49668
    Rick Pritchett
    Participant

      here is what i have so far.  I am wanting to add input checking so that the equations dont tank the messages if given junk input.

      proc Age_Calc {} {

    Viewing 2 reply threads
    • Author
      Replies
      • #63038
        Rick Pritchett
        Participant

          i may have found my own solution but would welcome input.

        • #63039
          James Cobane
          Participant

            Rickey,

            Along with your “string is digit” check, you could incorporate a valid date check with the “catch” and “clock scan” command to determine if you have a real date; i.e.

            if {[catch {clock scan  $DOB_n}]} {

               echo “If I’m here, the date had an error”

            }

            Since “catch” is successful (return code 1) when it encounters an error, this would indicate that the “clock scan” command couldn’t determine a date.  You can also use the “clock scan” command to normalize the date to a clock value for easier calculation along with the “getclock” command.

            Hope this helps.

            Jim Cobane

            Henry Ford Health

          • #63040
            Rick Pritchett
            Participant

              thanks for your advice i was able to use the commands you suggested to come up with a better way i believe this should do what i want:

              proc Age_Calc {} {

          Viewing 2 reply threads
          • The forum ‘Cloverleaf’ is closed to new topics and replies.