SET DATEFORMAT MDY; SELECT CASE WHEN ISDATE(@string) = 1 AND @string LIKE '[0-1][0-9]/[0-3][0-9]/[1-2][0-9][0-9][0-9]' THEN 1 ELSE 0 END;
If the result is 1, this is a valid date, but there is no guarantee that this is the date that the user had. If they enter:
06/07/2012
It is not possible to find out whether the place took place on June 7 or July 6. Itβs best to have users select dates from drop-down lists or calendar controls, which allows you to control the format and avoid unnecessary interpretation. Your application layer can use strongly typed variables / parameters and insert into correctly typed columns.
source share