<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.technet.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>SQL Nugget  - Dates are illogical</title><link>http://blogs.technet.com/b/andrew/archive/2010/08/20/sql-nugget-dates-are-illogical.aspx</link><description>Whether I am reading Chocky by John Wyndham or the 12 Caesers by Suetonius the illogical nature of a calendars can be annoying . In Chocky the alien wonders why we don’t have 16 months instead of 12 and why weeks aren’t made up of 8 days, and in the 12</description><dc:language>en-US</dc:language><generator>Telligent Evolution Platform Developer Build (Build: 5.6.50428.7875)</generator><item><title>re: SQL Nugget  - Dates are illogical</title><link>http://blogs.technet.com/b/andrew/archive/2010/08/20/sql-nugget-dates-are-illogical.aspx#3351384</link><pubDate>Mon, 23 Aug 2010 15:22:21 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:3351384</guid><dc:creator>Richard</dc:creator><description>&lt;p&gt;&amp;quot;... reading Chocky by John Wyndham ...&amp;quot;&lt;/p&gt;
&lt;p&gt;Great - now I can&amp;#39;t get the theme-tune from the TV series out of my head!&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3351384" width="1" height="1"&gt;</description></item><item><title>re: SQL Nugget  - Dates are illogical</title><link>http://blogs.technet.com/b/andrew/archive/2010/08/20/sql-nugget-dates-are-illogical.aspx#3351296</link><pubDate>Mon, 23 Aug 2010 07:36:48 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:3351296</guid><dc:creator>Andrew.Fryer</dc:creator><description>&lt;p&gt;Thanks for all the commments, first up I didn&amp;#39;t declare what type of date was being used here , but SQL Server form 2008 will not returen an error for this and does in fact return 10 sep 1752 on my US based virtual machine. &amp;nbsp;However as many of you spotted this didnt&amp;#39;t never existed in the UK, because we swapped calendars. so Karl if you want to send me your contact deatils you&amp;#39;ll get the SQL Server r2 polo shirt and say hi if you can make it to SQL Bits in York&lt;/p&gt;
&lt;p&gt;Andrew (afryer@microsoft.com)&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3351296" width="1" height="1"&gt;</description></item><item><title>re: SQL Nugget  - Dates are illogical</title><link>http://blogs.technet.com/b/andrew/archive/2010/08/20/sql-nugget-dates-are-illogical.aspx#3351294</link><pubDate>Mon, 23 Aug 2010 07:12:16 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:3351294</guid><dc:creator>Janis Norvelis</dc:creator><description>&lt;p&gt;I am not from the UK, but the last query should return NULL or maybe blow up, because there was no 10th of September in 1752.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3351294" width="1" height="1"&gt;</description></item><item><title>re: SQL Nugget  - Dates are illogical</title><link>http://blogs.technet.com/b/andrew/archive/2010/08/20/sql-nugget-dates-are-illogical.aspx#3351272</link><pubDate>Mon, 23 Aug 2010 02:44:36 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:3351272</guid><dc:creator>Ken</dc:creator><description>&lt;p&gt;Interesting trivia about 10/10/1752. &amp;nbsp;I didn&amp;#39;t know that until I googled/binged.&lt;/p&gt;
&lt;p&gt;However, the SELECT statement is returning an error, probably because it implicitly convert &amp;#39;17521010&amp;#39; into datetime data type, which has a minimum value of 1753-01-01. &amp;nbsp;If I explicitly convert it to datetime2 first, then SQL Server returns the date 1752-09-10, which didn&amp;#39;t really exist.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3351272" width="1" height="1"&gt;</description></item><item><title>re: SQL Nugget  - Dates are illogical</title><link>http://blogs.technet.com/b/andrew/archive/2010/08/20/sql-nugget-dates-are-illogical.aspx#3351250</link><pubDate>Sun, 22 Aug 2010 18:01:39 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:3351250</guid><dc:creator>cgw</dc:creator><description>&lt;p&gt;I know that for SQL 2005 and earlier, the earliest date you can store in a datetime field is &amp;#39;1753-01-01&amp;#39;, because this is the first full year after the United Kingdom finally adopted the Gregorian calendar. &amp;nbsp;&lt;/p&gt;
&lt;p&gt;The loss of 11 days happened between Sept. 2, 1572 and Sept. 14, 1572. So your query would not result in 1752-09-10, but I would guess you would want it to return 1752-08-30.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3351250" width="1" height="1"&gt;</description></item><item><title>re: SQL Nugget  - Dates are illogical</title><link>http://blogs.technet.com/b/andrew/archive/2010/08/20/sql-nugget-dates-are-illogical.aspx#3351223</link><pubDate>Sun, 22 Aug 2010 06:38:45 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:3351223</guid><dc:creator>Professor Davos</dc:creator><description>&lt;p&gt;This is when the British calendar changed from Julian to Gregorian and the days between the 3rd of September and the 13th of September were skipped. I am in Australia and this year predates the 1788 British colonisation.&lt;/p&gt;
&lt;p&gt;Subtracting a month from the 10th of October could put you back in August sometime, but how long is a month?&lt;/p&gt;
&lt;p&gt;In my opinion, subtracting a month from a date should return the same &amp;#39;dd&amp;#39; in the previous month. This is the only consistant outcome, so an &amp;#39;out of range&amp;#39; &amp;nbsp;error is appropriate. This is obviously the same conclusion that the real decision makers came to.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3351223" width="1" height="1"&gt;</description></item><item><title>re: SQL Nugget  - Dates are illogical</title><link>http://blogs.technet.com/b/andrew/archive/2010/08/20/sql-nugget-dates-are-illogical.aspx#3351191</link><pubDate>Sat, 21 Aug 2010 13:56:15 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:3351191</guid><dc:creator>Andy</dc:creator><description>&lt;p&gt;I&amp;#39;m not sure of the answer by there is a great book by David Ewing Duncan called &amp;quot;The Calendar&amp;quot; which should hold the answer, my copy is currently boxed up as I&amp;#39;m decorating at home. Alternative a trip to Greenwich to see the museum at the top of the hill would be fruitful&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3351191" width="1" height="1"&gt;</description></item><item><title>re: SQL Nugget  - Dates are illogical</title><link>http://blogs.technet.com/b/andrew/archive/2010/08/20/sql-nugget-dates-are-illogical.aspx#3351031</link><pubDate>Fri, 20 Aug 2010 12:02:56 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:3351031</guid><dc:creator>Karl Beran</dc:creator><description>&lt;p&gt;SELECT DATEADD(MONTH,-1,’17521010’)&lt;/p&gt;
&lt;p&gt;should return &lt;/p&gt;
&lt;p&gt;1) error -in reality as SQL server by default does not support dates prior to 17530101 for datatypes datetime or smalldatetime (for which it will perform an implicit conversion for the string &amp;#39;17521010&amp;#39;)&lt;/p&gt;
&lt;p&gt;2) NULL -logically as this date didn&amp;#39;t exist: on the switch to the gregorian calendar in england Wed 2 Sep was followed by Thu 14 Sep.&lt;/p&gt;
&lt;p&gt;3) 1752-09-10 if you change the syntax to SELECT DATEADD(MONTH,-1,cast(&amp;#39;17521010&amp;#39; as date)) or SELECT DATEADD(MONTH,-1,cast(&amp;#39;17521010&amp;#39; as datetime2)) which wouldn&amp;#39;t be a valid date in the UK but could be in spain, austria, hungary, turkey among others.&lt;/p&gt;
&lt;p&gt;check out my other interesting date post at:&lt;/p&gt;
&lt;p&gt;&lt;a rel="nofollow" target="_new" href="http://karlberan.spaces.live.com/blog/cns"&gt;karlberan.spaces.live.com/.../cns&lt;/a&gt;!451BD4B395B5A4C5!222.entry&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3351031" width="1" height="1"&gt;</description></item></channel></rss>