This SQL Server tutorial explains how to use the ISDATE function in SQL Server (Transact-SQL) with syntax and examples.
Description
In SQL Server (Transact-SQL), the ISDATE function returns 1 if the expression is a valid date. Otherwise, it returns 0.
Syntax
The syntax for the ISDATE function in SQL Servers (Transact-SQL) is:
ISDATE( expression )
Parameters or Arguments
expression
The value to test whether it is a date.
Note
- The ISDATE function returns 1, if the expression is a valid date.
- The ISDATE function returns 0, if the expression is NOT a valid date.
Applies To
The ISDATE function can be used in the following versions of SQL Servers (Transact-SQL):
- SQL Server 2017, SQL Server 2016, SQL Server 2014, SQL Server 2012, SQL Server 2008 R2, SQL Server 2008, SQL Server 2005
Example
Let’s look at some SQL Server ISDATE functions examples and explore how to use the ISDATE function in SQL Servers (Transact-SQL).
For example:
SELECT ISDATE('2014-05-01'); Result: 1 SELECT ISDATE('2014-05-01 10:03'); Result: 1 SELECT ISDATE('2014-05-01 10:03:32'); Result: 1 SELECT ISDATE('2014-05-01 10:03:32.001'); Result: 1 SELECT ISDATE('adglob.in'); Result: 0 SELECT ISDATE(123); Result: 0