Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase 12345»»»

Fun(?) with DATETIME2 Expand / Collapse
Author
Message
Posted Saturday, December 25, 2010 3:33 PM


SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: 2 days ago @ 8:19 AM
Points: 1,986, Visits: 1,612
Comments posted to this topic are about the item Fun(?) with DATETIME2
Post #1039225
Posted Sunday, December 26, 2010 5:58 AM


SSCrazy Eights

SSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy Eights

Group: General Forum Members
Last Login: Today @ 8:37 AM
Points: 8,287, Visits: 8,738
I learned something here - I expected it to fail because I thought datetime2 literals were required to specify time to the second (or more precisely), so I got it wrong.

However, the explanation is complete nonsense: there is no imaginable way that something expressing dates in the Gregorian calendar would fail to recognise 9th September 1752, just because some countries didn't at that time use the Gregorian calendar - most of the civilised world (all of the civilised world except Scotland and Ireland, who were unfortunately controlled by the uncivilised English ) adopted the Gregorian calendar well before that date, but even if no-one had yet adopted it the SQL type is not intended to express anything other than Gregorian dates. http://msdn.microsoft.com/en-us/library/bb677335%28v=SQL.100%29.aspx explicitly states that the calendar for datetime2 is Gregorian. It is utterly irrelevant that the benighted English (and their American colonies) called that day the 28th of August, in the Gregorian calendar and hence in datetime2 that day is called the 9th of September.


Tom
Post #1039247
Posted Sunday, December 26, 2010 6:26 AM


SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: 2 days ago @ 8:19 AM
Points: 1,986, Visits: 1,612
I wasn't expecting the question to appear today - I was advised it would be tomorrow. That would have given me the opportunity to express the "fun" side of the question as something lightweight for the holidays.

And whilst the explanation may indeed be "complete nonsense" according to BOL it does illustrate the differences that sometimes arise between the real world and one that exists purely of logic.

So, apologies for any upset caused. It was just supposed to be a bit of Christmas cheer.
Post #1039249
Posted Sunday, December 26, 2010 6:40 AM


SSCrazy Eights

SSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy Eights

Group: General Forum Members
Last Login: Today @ 8:37 AM
Points: 8,287, Visits: 8,738
Richard Warr (12/26/2010)
I wasn't expecting the question to appear today - I was advised it would be tomorrow. That would have given me the opportunity to express the "fun" side of the question as something lightweight for the holidays.

And whilst the explanation may indeed be "complete nonsense" according to BOL it does illustrate the differences that sometimes arise between the real world and one that exists purely of logic.

So, apologies for any upset caused. It was just supposed to be a bit of Christmas cheer.

No apologies needed, because no upset caused. As I said, I learned something from the question, and that is the only thing about QoTD that matters. So from where I stand, it was a really good question (questions I get right are somewhat boring) - and the fact that the explanation contains a bit of a red herring doesn't really matter.

But don't be surprised if someone who does know the data type and also knows that datetime2 literals as short as 10 characters are allowed answers "it works as expected" and then moans that they want their point back when told that's wrong.


Tom
Post #1039250
Posted Sunday, December 26, 2010 7:17 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Today @ 9:35 AM
Points: 12,206, Visits: 9,169
I like the point the question tries to make, but I have however some issues with the answers: how would you know what people expect? If someone not from the former British empire expects it to work, then answer A should be correct. In my country, 9 september 1752 is a perfectly valid date. I expected it to fail because there was no precision specified for the datetime2 datatype (I should check BOl to see if there is a default). So I got the question right for the wrong reason.

Conclusion: great question, but the answers could have been worked out better




How to post forum questions.
Need an answer? No, you need a question.
What’s the deal with Excel & SSIS?

Member of LinkedIn. My blog at LessThanDot.

MCSA SQL Server 2012 - MCSE Business Intelligence
Post #1039252
Posted Monday, December 27, 2010 12:28 AM


Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Tuesday, March 25, 2014 12:35 AM
Points: 1,172, Visits: 727
The transition from Julian to Gregorian Calendar: http://www.rundetaarn.dk/engelsk/observatorium/gregorian.html
September 14th 1752 - England and Scotland with colonies. Thursday, September 14th came after Wednesday, September 2nd.

Hmm, undoubtedly this Q will come once again. But for a different country... like Holland.
(Which should be The Netherlands by the way, but I digress)





Dutch Anti-RBAR League
Post #1039324
Posted Monday, December 27, 2010 12:38 AM


Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: 2 days ago @ 10:17 PM
Points: 1,381, Visits: 1,774
This question and it's response will invite mixed response, I am sure.

While it is good to know that DATETIME2 removes the "1753" restriction, it should also be known that logical validation of the value is NEVER done during assignment. This is why many (including me) would have expected the correct answer to be that it would run successfully (and it does!).

I would have expected the error if we had been validating the value with something like:

SELECT ISDATE('1752-09-09')

My deduction is that the question simply checks whether proper value assignment is done or not, which is done. It does not check for validity of the value, and hence that should not have been expected when building the answer to the question or in the explanation.

Happy Holidays!


Thanks & Regards,
Nakul Vachhrajani.
http://beyondrelational.com/modules/2/blogs/77/nakuls-blog.aspx
Be courteous. Drive responsibly.

Follow me on
Twitter: @nakulv_sql
Google Plus: +Nakul
Post #1039327
Posted Monday, December 27, 2010 12:58 AM


SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Yesterday @ 6:53 AM
Points: 2,393, Visits: 2,286
I learned more from QotD of last friday: "what type of shirts does Steve Jones wear on Fridays?"
Post #1039329
Posted Monday, December 27, 2010 3:42 AM
SSC Eights!

SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!

Group: General Forum Members
Last Login: Friday, October 25, 2013 7:20 AM
Points: 886, Visits: 285
Although I can understand the humor behind the question, I can't agree with the official result.

First, by 1700, the Gregorian calendar had been adopted by most of Europe (including Italy, Portugal, Spain, France, Austria, Germany, Poland, Scotland, Island, Greenland) and most of the colonies of South and Central America. So for the official answer to have a chance of being right, the question should have mentioned the date was about an event in the English colonies or in England.

Furthermore, the datetime2 is storing dates according to the Gregorian calendar. It is its only purpose.

It's not because a date is older than the adoption of a calendar in a certain country or even the invention of said calendar (1582 for the Gregorian calendar) that you can't express that date in the calendar. A calendar is merely a referential and scientifically, we can express in it whatever date we want.

Such an expression of a date becomes invalid only if you are in a very specific historic setting, like checking dates on correspondences dating from that period, because then the date doesn't make sense from the point of view of the writer of such a correspondence. We are hardly in that case when storing data in database unless you have a time machine and decide to set up a database in the past.



Post #1039356
Posted Monday, December 27, 2010 4:22 AM


Right there with Babe

Right there with BabeRight there with BabeRight there with BabeRight there with BabeRight there with BabeRight there with BabeRight there with BabeRight there with Babe

Group: General Forum Members
Last Login: Yesterday @ 6:14 AM
Points: 731, Visits: 1,943
I totally disagree that the question should have a compatibility also. I have SQL server 2008 with compatibility with 8.
Post #1039365
« Prev Topic | Next Topic »

Add to briefcase 12345»»»

Permissions Expand / Collapse