How to Use the ISDATE() Function in SQL Server: A Complete Guide

Rumman Ansari   Software Engineer   2024-07-21 09:41:26   5964  Share
Subject Syllabus DetailsSubject Details
☰ TContent
☰Fullscreen

Table of Content:

Syntax:


ISDATE() 

Checks if the given value, is a valid date, time, or datetime. Returns 1 for success, 0 for failure.

Code:


Select ISDATE('RABMO') -- returns 0
Select ISDATE(Getdate()) -- returns 1
Select ISDATE('2019-08-31 21:02:04.167') -- returns 1

Output:

The above code will produce the following result-


0
1
1

Note: For datetime2 values, IsDate returns ZERO.


Select ISDATE('2019-09-01 11:34:21.1918447') -- returns 0.



Stay Ahead of the Curve! Check out these trending topics and sharpen your skills.