Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Check Date if it is a valid Date 1

Status
Not open for further replies.

vignette1

Programmer
Jan 23, 2004
7
0
0
CH
Hello

How can I check the date in an easy way, if the date is
valid or invalid?

E.g.: Input-String is 31.02.2004 or 45.01.2004. I need
this string for a sql-select but I got an error because
the date is not valid for searching.

I don't want to check all months with valid days.

I wish something like this:

set error [check date (=input-string)]

error gives me 0 if it's ok or 1 if it's not ok.


Thanks a lot!

Thomas


 
You can use "catch" and look at the error returned:
Code:
set a 45.01.2004
set b 3/11/04
set c1 {clock scan $a}
set c2 {clock scan $b}
catch $c1 err1
catch $c2 err2
Now, look at $err1 and $err2. The first will be a string:
"unable to convert date-time string ...". The second will be a number (of seconds since Woodstock). You can trigger on the length, or the value, or however you want to handle it.

Bob Rashkin
rrashkin@csc.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top