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

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 isdate
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

talg80
Starting Member

5 Posts

Posted - 01/20/2013 :  04:05:55  Show Profile  Reply with Quote
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
Flowing Fount of Yak Knowledge

3873 Posts

Posted - 01/20/2013 :  06:02:11  Show Profile  Reply with Quote
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

India
52326 Posts

Posted - 01/21/2013 :  01:25:21  Show Profile  Reply with Quote
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
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.02 seconds. Powered By: Snitz Forums 2000