USE OF ISDATE IN SQL SERVER 2005

1. Syntax is : ISDATE ( expression )

2. Is an expression to be validated as a date. expression is any
expression, except text, ntext, and image expressions, that can be
implicitly converted to nvarchar.
It will check whether the expression is proper date or not.If proper it will return 1 else 0.

3. SELECT ISDATE(GETDATE()) –This will retrun 1 if the expression is a valid date.

4. SELECT ISDATE(‘dsfsdf’) –This will retrun 0 if the expression is not a valid date.

5. SELECT ISDATE(NULL) –This will retrun 0 if the expression is NULL.

6. SELECT ISDATE(1) –This will retrun 0 if the expression is int type.

7. SELECT ISDATE(’31/02/2009′)–This will retrun 0 if the expression is not a valid date.

Happy Programming.

Pawan Kumar
Pawankkmr@hotmail.com

Advertisements