ISDATE() Function in SQL Server
Last Updated :
18 Jan, 2021
Improve
ISDATE() function :
This function in SQL Server is used to check if the specified expression is a valid date or not.
Features :
- This function is used to find if the stated date is valid or not.
- This function comes under Date Functions.
- This function accepts only one parameter i.e, an expression.
- This function can also include time with the stated date.
- This function can either return 1 or 0.
Syntax :
ISDATE(expression)
Parameter :
This method accepts only one parameter as given below as follows.
- expression –Specified expression which is to be checked.
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.