I know there is a function called ISDATE to validate DATETIME columns, but it works only for the SMALLDATETIME and DATETIME types.
Is there a similar way to validate the new data type DATETIME2 in SQL Server 2008 and 2012?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
In SQL Server 2012, you can use
TRY_CONVERT:Results:
Or
TRY_PARSE:(Same results.)
Sorry that I don’t have a clever answer for you for < SQL Server 2012. You could, I guess, say
But that feels dirty.
TRY_CONVERTdocumentation on Microsoft DocsTRY_PARSEdocumentation on Microsoft Docs