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


DateTime data types


DateTime data types

Author
Message
Pulivarthi Sasidhar
Pulivarthi Sasidhar
SSCarpal Tunnel
SSCarpal Tunnel (4.4K reputation)SSCarpal Tunnel (4.4K reputation)SSCarpal Tunnel (4.4K reputation)SSCarpal Tunnel (4.4K reputation)SSCarpal Tunnel (4.4K reputation)SSCarpal Tunnel (4.4K reputation)SSCarpal Tunnel (4.4K reputation)SSCarpal Tunnel (4.4K reputation)

Group: General Forum Members
Points: 4352 Visits: 1030
Comments posted to this topic are about the item DateTime data types
Danny Ocean
Danny Ocean
Hall of Fame
Hall of Fame (3.4K reputation)Hall of Fame (3.4K reputation)Hall of Fame (3.4K reputation)Hall of Fame (3.4K reputation)Hall of Fame (3.4K reputation)Hall of Fame (3.4K reputation)Hall of Fame (3.4K reputation)Hall of Fame (3.4K reputation)

Group: General Forum Members
Points: 3380 Visits: 1549
Thanks for start my day with an easy question.

Still i found result as "Correct answers: 100%"

Nice question, keep it up my friend !!!

:-)

Thanks
Vinay Kumar
-----------------------------------------------------------------
Keep Learning - Keep Growing !!!
www.GrowWithSql.com
kapil_kk
kapil_kk
SSChampion
SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)

Group: General Forum Members
Points: 10533 Visits: 2778
Really good question Smile
+1

_______________________________________________________________
To get quick answer follow this link:
http://www.sqlservercentral.com/articles/Best+Practices/61537/
Primo Dang
Primo Dang
SSCrazy
SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)

Group: General Forum Members
Points: 2328 Visits: 1396
Got it right by elimination. There is no way a NULL value would be converted to an actual date (as far as I know, at least), so that eliminates answer B. Date types can't return an empty string (that would have to be char, varchar, etc.), so that eliminates answer A.

However, I never memorized the date that is equivalent to 0 and I didn't know if datetime, datetime2 and date had different conversions from integers, so if there had been an answer such as NULL, 1900-01-01 00:00:000, 1753-01-01 00:00:000, 1900-01-01, I might had gotten it wrong. Guess I learned that much from this question, then.

Thanks, Sasidhar Pulivarthi! :-D

Edit: changed "don't know if datetime (...) have different conversions from integers" to "didn't know", which made me realized I actually learned something new here. w00t
jlennartz
jlennartz
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: 1148 Visits: 1197
If default values are returned as in your explaination why are not all the values except null returned in this format, "1900-01-01 00:00:00.0000000". How did they get switched to "Jan 1 1900 12:00AM"?
SQLRNNR
SQLRNNR
SSC Guru
SSC Guru (143K reputation)SSC Guru (143K reputation)SSC Guru (143K reputation)SSC Guru (143K reputation)SSC Guru (143K reputation)SSC Guru (143K reputation)SSC Guru (143K reputation)SSC Guru (143K reputation)

Group: General Forum Members
Points: 143373 Visits: 18649
Thanks

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

demonfox
demonfox
Hall of Fame
Hall of Fame (3.6K reputation)Hall of Fame (3.6K reputation)Hall of Fame (3.6K reputation)Hall of Fame (3.6K reputation)Hall of Fame (3.6K reputation)Hall of Fame (3.6K reputation)Hall of Fame (3.6K reputation)Hall of Fame (3.6K reputation)

Group: General Forum Members
Points: 3623 Visits: 1192
Primo Dang (4/11/2013)
Got it right by elimination
Thanks, Sasidhar Pulivarthi! :-D


+1

Thanks for the question ..

~ demonfox
___________________________________________________________________
Wondering what I would do next , when I am done with this one Ermm
demonfox
demonfox
Hall of Fame
Hall of Fame (3.6K reputation)Hall of Fame (3.6K reputation)Hall of Fame (3.6K reputation)Hall of Fame (3.6K reputation)Hall of Fame (3.6K reputation)Hall of Fame (3.6K reputation)Hall of Fame (3.6K reputation)Hall of Fame (3.6K reputation)

Group: General Forum Members
Points: 3623 Visits: 1192
jlennartz (4/11/2013)
If default values are returned as in your explaination why are not all the values except null returned in this format, "1900-01-01 00:00:00.0000000". How did they get switched to "Jan 1 1900 12:00AM"?


the default conversion style for cast and convert is 0 for datetime and 121 for datetime2 ; that's how !!

ref: http://msdn.microsoft.com/en-gb/library/ms187928.aspx

~ demonfox
___________________________________________________________________
Wondering what I would do next , when I am done with this one Ermm
manik_anu
manik_anu
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: 1107 Visits: 335
Primo Dang (4/11/2013)
Got it right by elimination. There is no way a NULL value would be converted to an actual date (as far as I know, at least), so that eliminates answer B. Date types can't return an empty string (that would have to be char, varchar, etc.), so that eliminates answer A.

However, I never memorized the date that is equivalent to 0 and I didn't know if datetime, datetime2 and date had different conversions from integers, so if there had been an answer such as NULL, 1900-01-01 00:00:000, 1753-01-01 00:00:000, 1900-01-01, I might had gotten it wrong. Guess I learned that much from this question, then.

Thanks, Sasidhar Pulivarthi! :-D

Edit: changed "don't know if datetime (...) have different conversions from integers" to "didn't know", which made me realized I actually learned something new here. w00t


i too memorize if we use datatime2 datatype that gives the datetime value as '1900-01-01 00:00:00.0000000 '. That is the reason to clicked the third answer... it's correct.....

thanks for this question.. nice one....

Manik
You cannot get to the top by sitting on your bottom.
jlennartz
jlennartz
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: 1148 Visits: 1197
demonfox (4/11/2013)
jlennartz (4/11/2013)
If default values are returned as in your explaination why are not all the values except null returned in this format, "1900-01-01 00:00:00.0000000". How did they get switched to "Jan 1 1900 12:00AM"?


the default conversion style for cast and convert is 0 for datetime and 121 for datetime2 ; that's how !!

ref: http://msdn.microsoft.com/en-gb/library/ms187928.aspx


Thank You
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