Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 isdate

Author  Topic 

talg80
Starting Member

5 Posts

Posted - 2013-01-20 : 04:05:55
hello ,

i have a problem with the isdate function , when i run it with the string Select isdate('201212') i get the result 1 But with Select isdate('201301') i get 0 , it seams like the date table of sql in not updated and any value above 201212 get 0.

how can i fix that?

James K
Master Smack Fu Yak Hacker

3873 Posts

Posted - 2013-01-20 : 06:02:11
SQL Server is interpreting the data in the dd/mm/yy with a two-digit year (dateformat = dmy). So obviously month = 13 is not a valid date. This MSDN page has information on setting the format: http://msdn.microsoft.com/en-us/library/ms189491.aspx

If you are trying to write a literal for January 2013, use '20130101'. That will give you January 1, 2013.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-01-21 : 01:25:21
quote:
Originally posted by talg80

hello ,

i have a problem with the isdate function , when i run it with the string Select isdate('201212') i get the result 1 But with Select isdate('201301') i get 0 , it seams like the date table of sql in not updated and any value above 201212 get 0.

how can i fix that?


see

http://visakhm.blogspot.in/2011/12/why-iso-format-is-recommended-while.html

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -