SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Fun(?) with DATETIME2


Fun(?) with DATETIME2

Author
Message
pitvax
pitvax
Old Hand
Old Hand (361 reputation)Old Hand (361 reputation)Old Hand (361 reputation)Old Hand (361 reputation)Old Hand (361 reputation)Old Hand (361 reputation)Old Hand (361 reputation)Old Hand (361 reputation)

Group: General Forum Members
Points: 361 Visits: 157
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 ...
David Data
David Data
SSCommitted
SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)

Group: General Forum Members
Points: 1799 Visits: 829
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 Date('1752-09-02') + 1 would give the correct result depending on country. e.g. '1752-09-13' in England (and I think the rest of the UK), and '1752-09-03' 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.
Richard M Karpel
Richard M Karpel
Ten Centuries
Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)

Group: General Forum Members
Points: 1051 Visits: 62
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.
vk-kirov
vk-kirov
SSCertifiable
SSCertifiable (5.7K reputation)SSCertifiable (5.7K reputation)SSCertifiable (5.7K reputation)SSCertifiable (5.7K reputation)SSCertifiable (5.7K reputation)SSCertifiable (5.7K reputation)SSCertifiable (5.7K reputation)SSCertifiable (5.7K reputation)

Group: General Forum Members
Points: 5656 Visits: 4408
I wonder how many records in one's database containing year 1752 :-D
Brandie Tarvin
Brandie Tarvin
SSC Guru
SSC Guru (92K reputation)SSC Guru (92K reputation)SSC Guru (92K reputation)SSC Guru (92K reputation)SSC Guru (92K reputation)SSC Guru (92K reputation)SSC Guru (92K reputation)SSC Guru (92K reputation)

Group: General Forum Members
Points: 92423 Visits: 9544
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.

Brandie Tarvin, MCITP Database AdministratorLiveJournal Blog: http://brandietarvin.livejournal.com/On LinkedIn!, Google+, and Twitter.Freelance Writer: ShadowrunLatchkeys: Nevermore, Latchkeys: The Bootleg War, and Latchkeys: Roscoes in the Night are now available on Nook and Kindle.
David Data
David Data
SSCommitted
SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)

Group: General Forum Members
Points: 1799 Visits: 829
BTW Microsoft's documentation has an error too - it says "Accuracy 100 nanoseconds". This is of course the Resolution (or Precision) of the data.

The accuracy will depend on the original source of the time-stamp - which in my experience can vary from minutes (old server nobody cares about) to milliseconds (typical NTP setup). You'll only get 100 nSec accuracy in systems very tightly coupled to GPS (or a satellite-coordinated atomic clock). Even then, by the time some code has decided to date an event many many μSecs will have passed.
Phil Huffstatler
Phil Huffstatler
SSC Veteran
SSC Veteran (265 reputation)SSC Veteran (265 reputation)SSC Veteran (265 reputation)SSC Veteran (265 reputation)SSC Veteran (265 reputation)SSC Veteran (265 reputation)SSC Veteran (265 reputation)SSC Veteran (265 reputation)

Group: General Forum Members
Points: 265 Visits: 65
Fired up my local SQL 2008 Mgmt Studio, put the code into the query window (on Master), hit F5, and got: 1752-09-09 00:00:00.0000000


So, why do I now have an X on my test answer? I wasn't wrong, my SQL install isn't wrong... the world is.... Smile

Oh well,
Phil
SQLRNNR
SQLRNNR
SSC Guru
SSC Guru (145K reputation)SSC Guru (145K reputation)SSC Guru (145K reputation)SSC Guru (145K reputation)SSC Guru (145K reputation)SSC Guru (145K reputation)SSC Guru (145K reputation)SSC Guru (145K reputation)

Group: General Forum Members
Points: 145005 Visits: 18651
Total guess on this question. The question asks for opinions and the answer is an opinion. Based on that, I see more than one possible answer.

Jason...AKA CirqueDeSQLeil
_______________________________________________
I have given a name to my pain...MCM SQL Server, MVP
SQL RNNR
Posting Performance Based Questions - Gail Shaw
Learn Extended Events

SQL-DBA-01
SQL-DBA-01
SSCoach
SSCoach (19K reputation)SSCoach (19K reputation)SSCoach (19K reputation)SSCoach (19K reputation)SSCoach (19K reputation)SSCoach (19K reputation)SSCoach (19K reputation)SSCoach (19K reputation)

Group: General Forum Members
Points: 19135 Visits: 3813
I guessed Option:1.

SSMS QA says: 1752-09-09 00:00:00.0000000

Not sure, why the correct answer is :: Option No: 3

Thanks.
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum








































































































































































SQLServerCentral


Search