Open In App

ISDATE() Function in SQL Server

ISDATE() function :
This function in SQL Server is used to check if the specified expression is a valid date or not.

Features :



Syntax :

ISDATE(expression)

Parameter :
This method accepts only one parameter as given below as follows.



Returns :
It returns 1 if the stated expression is a valid date else it returns 0.

Example-1 :
Using ISDATE() function and getting the output.

SELECT ISDATE('2020/01/03');

Output :

1

Example-2 :
Using ISDATE() function with a variable and getting the desired output.

DECLARE @exp VARCHAR(50);
SET @exp= '2021/12/25';
SELECT ISDATE(@exp);

Output :

1

Example-3 :
Using ISDATE() function with date as parameter which includes time as well.

SELECT ISDATE('2021/01/03 08:55');

Output :

1

Example-4 :
Using ISDATE() function with a invalid date and getting the output.

SELECT ISDATE('2021/01/32 08:55');

Output :

0

Application :
This function is used to check if the given expression is a valid date or not.

Article Tags :
SQL