Sql Server Isdate Function

SQL Server: ISDATE Function

In this post 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 Server (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 Server (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 function examples and explore how to use the ISDATE function in SQL Server (Transact-SQL).

For example:

SELECT ISDATE('2014-05-01');
Output: 1

SELECT ISDATE('2014-05-01 10:03');
Output: 1

SELECT ISDATE('2014-05-01 10:03:32');
Output: 1

SELECT ISDATE('2014-05-01 10:03:32.001');
Output: 1

SELECT ISDATE('AODBA.com');
Output: 0

SELECT ISDATE(123);
Output: 0