December 25, 2010 at 3:33 pm
Comments posted to this topic are about the item Fun(?) with DATETIME2
December 26, 2010 at 5:58 am
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 :laugh:) 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
December 26, 2010 at 6:26 am
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.
December 26, 2010 at 6:40 am
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
December 26, 2010 at 7:17 am
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 😀
Need an answer? No, you need a question
My blog at https://sqlkover.com.
MCSE Business Intelligence - Microsoft Data Platform MVP
December 27, 2010 at 12:28 am
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)
December 27, 2010 at 12:38 am
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://nakulvachhrajani.com
Follow me on
Twitter: @sqltwins
December 27, 2010 at 12:58 am
I learned more from QotD of last friday: "what type of shirts does Steve Jones wear on Fridays?"
December 27, 2010 at 3:42 am
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. :hehe:
December 27, 2010 at 4:22 am
I totally disagree that the question should have a compatibility also. I have SQL server 2008 with compatibility with 8.:-)
December 27, 2010 at 5:19 am
gserdijn 2010-12-27
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)
This is also my addition to this question. I am living in Czech Republic (formerly Czech Lands) and there was Gregorian Calendar adopted 'several' years before - It was in 1584 ... days between 6th January and 17th January 1584 was 'canceled'. 😉
__________________________________
Standing on the shoulders of giants ...
December 27, 2010 at 5:53 am
I agree with cdiebolt. While there was no such date in England's dating system at the time, it's a perfectly valid date in the Gregorian calendar, and corresponds to various dates in various countries' national systems.
So the function DOES do what I expected, hence it runs perfectly. "Perfect" is in the of the beholder, so not a word to be used in a specification - unless itself specified for the occasion. Please make the possible answers unambiguous in future - and scope the conditions precisely too.
I wonder if anyone has created a nation-sensitive historic date system in which [font="Courier New"]Date('1752-09-02') + 1[/font] would give the correct result depending on country. e.g. [font="Courier New"]'1752-09-13'[/font] in England (and I think the rest of the UK), and [font="Courier New"]'1752-09-03'[/font] in The Netherlands? It would be hard to do; you couldn't use ISO country codes to indicate locale, as some no longer exist and others (e.g. Belgium) were parts of multiple other countries at the time.
December 27, 2010 at 6:15 am
I did not know about the 1752, though I should have. :hehe: I totally expected it to work after going over the BOL entry on datetime2. It is the first time, that I do not mind getting an answer wrong, cause I learned something new & useful. Thx for the excellent question.
Rick Karpel
December 27, 2010 at 6:50 am
I wonder how many records in one's database containing year 1752 😀
December 27, 2010 at 8:27 am
Interesting. I didn't know the Gregorian calendar adoption for the British Empire was in 1752. All the history I studied talked about the Gregorian calendar being created in the 1500's, so I just assumed adoption was across the board in the same time frame.
Viewing 15 posts - 1 through 15 (of 81 total)
You must be logged in to reply to this topic. Login to reply