dstjohnjr
asked on
SQL Stored Procedure to validate date
I am looking to design a SQL Stored Procedure (SQL Server 2000) that will validate a date. Now, before you think this is a normal date, here is a more specific definition of what I am looking to validate.
The field in the DB is a varchar field (10 chars I think) and the date format is: YYYYMMDD (i.e. 20071015)
It might sound a little whacked (and it is) but this is what I have to work with.
Of course, the SQL SP would have a parameter that would need to be passed to it, that being the date string as outlined above.
TIA for any help!
The field in the DB is a varchar field (10 chars I think) and the date format is: YYYYMMDD (i.e. 20071015)
It might sound a little whacked (and it is) but this is what I have to work with.
Of course, the SQL SP would have a parameter that would need to be passed to it, that being the date string as outlined above.
TIA for any help!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
... but that will return 1 to '20071939' as well ... and that really is not a valid date.
Hope this helps ...
Hope this helps ...
... you could combine the two:
... oops that is what mmcdermaid did
... sorry, too early I guess :-)
The '20071939' thing is not true as I said before !
... oops that is what mmcdermaid did
... sorry, too early I guess :-)
The '20071939' thing is not true as I said before !
I didn't check if ISDATE('20071939') = 0 or 1.... maybe the questioner can tell us :)
It's a 0, so your AND clause filters these kinds of values.
That's the part I missed ...
That's the part I missed ...
ASKER
Thanks for the assistance experts and sorry for the delay.
returns 1 if the argument is a valid date, 0 otherwise.
Hope this helps ...