Technical Article

Issues with IsDate()

,

Editor: This is for scripts. If you have a script, please include thatin the "script" box

Issues with ISDate() function in SQL Server

 

ISDATE function returns 1 even for a numeric (for ex: 1753). The reason is valid range of years is 1753 - 9999. To overcome this we have to use STUFF function

 

Select isdate('1752') -- it returns 0 which is valid
Select isdate('1753') -- it returns 1 which is invalid

--WorkAround
select isdate(Stuff('1753', 4, 0, ' ')) -- returns 0 which is valid

Rate

1.44 (9)

You rated this post out of 5. Change rating

Share

Share

Rate

1.44 (9)

You rated this post out of 5. Change rating