Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase «««23456

Dating for DBAs - a second date Expand / Collapse
Author
Message
Posted Thursday, April 14, 2011 8:59 AM


Hall of Fame

Hall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of Fame

Group: General Forum Members
Last Login: 2 days ago @ 8:35 AM
Points: 3,642, Visits: 72,429
Duncan Pryde (4/13/2011)
Henrico Bekker (4/12/2011)
All 4 options work? one of those questions again...pick 2 out of 4 correct answers...a quessing game again.


Try this:

SET DATEFORMAT ydm
GO
SELECT CAST('2011-04-28' AS DATETIME)

or this:

SET LANGUAGE British
GO
SELECT CAST('2011-04-28' AS DATETIME)

and do the same for the other date types, and you'll see that DATETIME and SMALLDATETIME produce an error while DATE and DATETIME2 don't.

So no guessing required!

Duncan


Just look up the various data types in books online.

Only DATE and DATETIME2 have Default String literals... the others do not. And the default string literals are YYYY-MM-DD :)




--Mark Tassin
MCITP - SQL Server DBA
Proud member of the Anti-RBAR alliance.
For help with Performance click this link
For tips on how to post your problems
Post #1093598
Posted Thursday, April 14, 2011 11:12 AM


SSC Eights!

SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!

Group: General Forum Members
Last Login: Thursday, June 26, 2014 5:34 AM
Points: 897, Visits: 1,486
Fortunately I got it right because I somehow knew it'd be a tricky question and I'm studying the new data types in MSSQL 2008.

But I've never tested them that way and I see a lot of errors when dealing with datetime/smalldatetime conversion to other data types around the internet.

Hoepfully those new date and time types will make our lives easier.

Thank you for the question. :)

Best regards,



Best regards,

Andre Guerreiro Neto

Database Analyst
http://www.softplan.com.br
MCITPx1/MCTSx2
Post #1093690
Posted Tuesday, April 19, 2011 12:21 PM


SSC-Addicted

SSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-Addicted

Group: General Forum Members
Last Login: Tuesday, March 25, 2014 4:09 PM
Points: 434, Visits: 113
All 4 work on my SQL 2008.
bogus question...


Dennis Parks
MCSE, MCDBA, MCSD, MCAD, MCTS
Post #1095884
Posted Tuesday, April 19, 2011 12:53 PM
Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Thursday, January 31, 2013 8:01 AM
Points: 1,232, Visits: 1,046
dennisparks (4/19/2011)
All 4 work on my SQL 2008.
bogus question...

Really?!?!

Try running either
SET DATEFORMAT ydm
or
SET LANGUAGE British

and then see what your results are.

Like someone already pointed out BOL states that DATE and DATETIME2 have Default String literals of YYYY-MM-DD the others do not.
Post #1095909
Posted Tuesday, April 19, 2011 4:21 PM


SSC-Addicted

SSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-Addicted

Group: General Forum Members
Last Login: Tuesday, March 25, 2014 4:09 PM
Points: 434, Visits: 113
I don't remember the question stating to change the default date setting.
under default settings, they work fine.


Dennis Parks
MCSE, MCDBA, MCSD, MCAD, MCTS
Post #1096016
Posted Tuesday, April 19, 2011 4:38 PM
Hall of Fame

Hall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of Fame

Group: General Forum Members
Last Login: 2 days ago @ 9:42 AM
Points: 3,869, Visits: 3,619
dennisparks (4/19/2011)
I don't remember the question stating to change the default date setting.
under default settings, they work fine.


The question clearly stated which ones work 'regardless of any date format or language settings?'.
Post #1096021
Posted Tuesday, April 19, 2011 4:52 PM


SSC-Addicted

SSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-Addicted

Group: General Forum Members
Last Login: Tuesday, March 25, 2014 4:09 PM
Points: 434, Visits: 113
ok, then I guess it tricked me. :~)


Dennis Parks
MCSE, MCDBA, MCSD, MCAD, MCTS
Post #1096025
Posted Friday, May 13, 2011 2:54 AM
Valued Member

Valued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued Member

Group: General Forum Members
Last Login: Tuesday, July 15, 2014 7:54 AM
Points: 60, Visits: 201
Something is wrong with that answer provided.
Post #1108257
Posted Friday, May 13, 2011 3:01 AM
SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: Today @ 8:12 AM
Points: 1,610, Visits: 5,476
Mr Quillz (5/13/2011)
Something is wrong with that answer provided.


No, there isn't. Try reading the rest of the thread.
Post #1108258
« Prev Topic | Next Topic »

Add to briefcase «««23456

Permissions Expand / Collapse