April 2, 2010 at 8:08 am
SanjayAttray (4/2/2010)
The ultimate guide to the datetime datatypes
Sanjay,
Thank you for the excellent reference, and its explanation of "Why 1753".
-c
April 2, 2010 at 9:20 am
Hi all,
This is an extrapolated question from the actual QoD, but I would like to know the reason (coz of knowledge gaining reason)
Why the 'mmm' part in the RESULT section giving a different value than I entered through the character string as shown below.
SET DATEFORMAT MDY
DECLARE @dmy datetime
SELECT @dmy = '12/31/99 12:13:12:012'
SELECT @dmy
RESULT:
1999-12-31 12:13:12.013
Thanks
big[M]
John
April 2, 2010 at 9:44 am
bigM (4/2/2010)
Hi all,This is an extrapolated question from the actual QoD, but I would like to know the reason (coz of knowledge gaining reason)
Why the 'mmm' part in the RESULT section giving a different value than I entered through the character string as shown below.
SET DATEFORMAT MDY
DECLARE @dmy datetime
SELECT @dmy = '12/31/99 12:13:12:012'
SELECT @dmy
RESULT:
1999-12-31 12:13:12.013
Thanks
big[M]
The accuracy of datetime is not to the millisecond, but to 1/300 of a second. So each second is divided into 300 slices of 3 1/3 milliseconds. And because display uses milliseconds, you see the values rounded to the millisecond: 0.000, 0.003, 0.007, 0.010, 0.013, 0.017, .....
April 2, 2010 at 11:07 am
Paul White NZ (4/2/2010)
I wonder how long it will be before someone complains that this QotD is misleading and incorrect since the question specifies "(yyyy/mm/dd)" format and the answers are all in YYYY-MM-DD format?:laugh:
Surprised it hasn't happened yet.
Jason...AKA CirqueDeSQLeil
_______________________________________________
I have given a name to my pain...MCM SQL Server, MVP
SQL RNNR
Posting Performance Based Questions - Gail Shaw[/url]
Learn Extended Events
April 2, 2010 at 11:08 am
Nice question.
Thanks
Jason...AKA CirqueDeSQLeil
_______________________________________________
I have given a name to my pain...MCM SQL Server, MVP
SQL RNNR
Posting Performance Based Questions - Gail Shaw[/url]
Learn Extended Events
April 2, 2010 at 11:09 am
Voitek (4/2/2010)
I did a cast(0 as datetime), but then I thought hmm. can negatives be converted to datetime? I picked 64000, but that failed, so then I went incrementally to -53690 beyond which the cast fails.I don't think the QOD is misleading. The oldest date you can store is -53690, which is 1-1-1753.
Nice information. Thanks for providing it.
Jason...AKA CirqueDeSQLeil
_______________________________________________
I have given a name to my pain...MCM SQL Server, MVP
SQL RNNR
Posting Performance Based Questions - Gail Shaw[/url]
Learn Extended Events
April 2, 2010 at 11:24 am
CirquedeSQLeil (4/2/2010)
Surprised it hasn't happened yet.
vk-kirov covered it!
April 2, 2010 at 11:33 am
Paul White NZ (4/2/2010)
CirquedeSQLeil (4/2/2010)
Surprised it hasn't happened yet.vk-kirov covered it!
I found that comment funny.
Jason...AKA CirqueDeSQLeil
_______________________________________________
I have given a name to my pain...MCM SQL Server, MVP
SQL RNNR
Posting Performance Based Questions - Gail Shaw[/url]
Learn Extended Events
April 2, 2010 at 12:28 pm
I found this one fairly easy. Good discussion, which adds to question.
April 5, 2010 at 2:30 am
I didn't knew it.. Great one to know...
April 5, 2010 at 9:48 am
This is a very interesting question, thank you Carla. I knew that 1753-01-01 was selected as the first available date, but had no clue why the SQL Server team chose it. The number -53690 does not appear to be of any significance, so I learned something new today.
Oleg
April 5, 2010 at 11:56 pm
same with me ...whenever i selects date columns it shows same..
April 6, 2010 at 9:47 am
Lynn Pettis (4/2/2010)
I found this one fairly easy. Good discussion, which adds to question.
I have to admit, I did not find this one as easy. I did have to do some checking and research.
Jason...AKA CirqueDeSQLeil
_______________________________________________
I have given a name to my pain...MCM SQL Server, MVP
SQL RNNR
Posting Performance Based Questions - Gail Shaw[/url]
Learn Extended Events
April 8, 2010 at 8:20 am
Any idea what the latest date is? I got as far as 500,000 days into the future before i gave up, I doubt i'd have much use for this unless i'm using DBCC timewarp though 🙂
April 8, 2010 at 8:39 am
From MS SQL documentation:
datetime: January 1, 1753, through December 31, 9999
smalldatetime: January 1, 1900, through June 6, 2079
Note:
datetime is stored as two 4-byte integers for days from 1/1/1900 and milliseconds since midnight.
smalldatetime is stored as two 2-byte integers for days from 1/1/1900 and minutes since midnight.
Viewing 15 posts - 16 through 30 (of 33 total)
You must be logged in to reply to this topic. Login to reply