Date/Time Functions – ISDATE()

I am tireless with my writing of short articles or tidbits on Transaction SQL date/time functions.

Most, if not all, modern day computer systems collect data which contains dates and times.

Sometimes data comes from external sources in a textual format. How do we know if the data is a valid date/time variable?

Today, I will be exploring the ISDATE() function that takes a character string as input and returns an integer as output. A numeric 1 represents a valid date and a numeric 0 represents an invalid date.

The examples below are sample calls to the function. The inputs puts are valid strings, invalid strings, a null value and a empty string.

The output from the test is listed below.

In summary, the ISDATE() function is a quick way to determine if a string can be converted to a date/time variable. Next time, I will be talking about the end of month function EOMONTH() which was introduced to TSQL in 2012.

Related posts

Leave a Comment