In SQL Server, you can use the ISDATE()
function to check if a value is a valid date.
To be more specific, this function only checks whether the value is a valid date, time, or datetime value, but not a datetime2 value. If you provide a datetime2 value, ISDATE()
will tell you it’s not a date (it will return 0
).
This article contains examples of this function.