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 (329 reputation)Old Hand (329 reputation)Old Hand (329 reputation)Old Hand (329 reputation)Old Hand (329 reputation)Old Hand (329 reputation)Old Hand (329 reputation)Old Hand (329 reputation)

Group: General Forum Members
Points: 329 Visits: 156
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
SSC Eights!
SSC Eights! (869 reputation)SSC Eights! (869 reputation)SSC Eights! (869 reputation)SSC Eights! (869 reputation)SSC Eights! (869 reputation)SSC Eights! (869 reputation)SSC Eights! (869 reputation)SSC Eights! (869 reputation)

Group: General Forum Members
Points: 869 Visits: 828
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
SSC Eights!
SSC Eights! (993 reputation)SSC Eights! (993 reputation)SSC Eights! (993 reputation)SSC Eights! (993 reputation)SSC Eights! (993 reputation)SSC Eights! (993 reputation)SSC Eights! (993 reputation)SSC Eights! (993 reputation)

Group: General Forum Members
Points: 993 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
SSCarpal Tunnel
SSCarpal Tunnel (4.3K reputation)SSCarpal Tunnel (4.3K reputation)SSCarpal Tunnel (4.3K reputation)SSCarpal Tunnel (4.3K reputation)SSCarpal Tunnel (4.3K reputation)SSCarpal Tunnel (4.3K reputation)SSCarpal Tunnel (4.3K reputation)SSCarpal Tunnel (4.3K reputation)

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

Group: General Forum Members
Points: 38529 Visits: 9279
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
SSC Eights!
SSC Eights! (869 reputation)SSC Eights! (869 reputation)SSC Eights! (869 reputation)SSC Eights! (869 reputation)SSC Eights! (869 reputation)SSC Eights! (869 reputation)SSC Eights! (869 reputation)SSC Eights! (869 reputation)

Group: General Forum Members
Points: 869 Visits: 828
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 (213 reputation)SSC Veteran (213 reputation)SSC Veteran (213 reputation)SSC Veteran (213 reputation)SSC Veteran (213 reputation)SSC Veteran (213 reputation)SSC Veteran (213 reputation)SSC Veteran (213 reputation)

Group: General Forum Members
Points: 213 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 (67K reputation)SSC Guru (67K reputation)SSC Guru (67K reputation)SSC Guru (67K reputation)SSC Guru (67K reputation)SSC Guru (67K reputation)SSC Guru (67K reputation)SSC Guru (67K reputation)

Group: General Forum Members
Points: 67513 Visits: 18570
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

SQL-DBA-01
SQL-DBA-01
SSCrazy Eights
SSCrazy Eights (8.4K reputation)SSCrazy Eights (8.4K reputation)SSCrazy Eights (8.4K reputation)SSCrazy Eights (8.4K reputation)SSCrazy Eights (8.4K reputation)SSCrazy Eights (8.4K reputation)SSCrazy Eights (8.4K reputation)SSCrazy Eights (8.4K reputation)

Group: General Forum Members
Points: 8445 Visits: 3581
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