Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Dating for DBAs - a second date


Dating for DBAs - a second date

Author
Message
Duncan Pryde
Duncan Pryde
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: 3396 Visits: 1552
CirquedeSQLeil (4/12/2011)
This is a good question - thanks Duncan


Thanks for the compliment Jason - glad you liked it.
Henrico Bekker
Henrico Bekker
SSCrazy
SSCrazy (2K reputation)SSCrazy (2K reputation)SSCrazy (2K reputation)SSCrazy (2K reputation)SSCrazy (2K reputation)SSCrazy (2K reputation)SSCrazy (2K reputation)SSCrazy (2K reputation)

Group: General Forum Members
Points: 2027 Visits: 3255
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


question doesnt state that you need to SET LANGUAGE....
anyway.

----------------------------------------------
Msg 8134, Level 16, State 1, Line 1
Divide by zero error encountered.
Stewart "Arturius" Campbell
Stewart "Arturius" Campbell
SSCertifiable
SSCertifiable (5.8K reputation)SSCertifiable (5.8K reputation)SSCertifiable (5.8K reputation)SSCertifiable (5.8K reputation)SSCertifiable (5.8K reputation)SSCertifiable (5.8K reputation)SSCertifiable (5.8K reputation)SSCertifiable (5.8K reputation)

Group: General Forum Members
Points: 5786 Visits: 7137
Thanks for the question,
Good to get the brain juices working so early in the morning.

____________________________________________
Space, the final frontier? not any more...
All limits henceforth are self-imposed.
“libera tute vulgaris ex”
Duncan Pryde
Duncan Pryde
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: 3396 Visits: 1552
Henrico Bekker (4/13/2011)

question doesnt state that you need to SET LANGUAGE....
anyway.


It says:

"regardless of any date format or language settings".

You change language settings using SET LANGUAGE and date format settings using SET DATEFORMAT.

Duncan
Nakul Vachhrajani
Nakul Vachhrajani
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: 1824 Visits: 2127
Duncan Pryde (4/13/2011)
Nakul Vachhrajani (4/13/2011)
Thank-you, Duncan for this wonderful series!


You're welcome - although I'd hesitate to call 2 questions a series! Unless you're expecting more? Blink


Definitely expecting more :-) Maybe I like them because a few years ago, we made major changes to our product to support globalization/internationalization and came across all these issues then. These QotDs are great learning opportunities for anyone who would want to work on a product that would work no matter where you take it.

Thanks & Regards,
Nakul Vachhrajani.
http://nakulvachhrajani.com
Be courteous. Drive responsibly.

Follow me on
Twitter: @sqltwins
Google Plus: +Nakul
Carlo Romagnano
Carlo Romagnano
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: 3614 Visits: 3236
Thank you very much for this beautiful qotd.
It's unbelievable, but true, only new types DATE and DATETIME2 work in any case.
Koen Verbeeck
Koen Verbeeck
SSCoach
SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)

Group: General Forum Members
Points: 16455 Visits: 13207
Dammit, I got it wrong because I've misread the question.
Anyway, it was a great question, thanks Duncan.



How to post forum questions.
Need an answer? No, you need a question.
What’s the deal with Excel & SSIS?

Member of LinkedIn. My blog at SQLKover.

MCSA SQL Server 2012 - MCSE Business Intelligence
malleswarareddy_m
malleswarareddy_m
SSCrazy
SSCrazy (2K reputation)SSCrazy (2K reputation)SSCrazy (2K reputation)SSCrazy (2K reputation)SSCrazy (2K reputation)SSCrazy (2K reputation)SSCrazy (2K reputation)SSCrazy (2K reputation)

Group: General Forum Members
Points: 2011 Visits: 1189
good Question

Malleswarareddy
I.T.Analyst
MCITP(70-451)
Brigadur
Brigadur
Mr or Mrs. 500
Mr or Mrs. 500 (597 reputation)Mr or Mrs. 500 (597 reputation)Mr or Mrs. 500 (597 reputation)Mr or Mrs. 500 (597 reputation)Mr or Mrs. 500 (597 reputation)Mr or Mrs. 500 (597 reputation)Mr or Mrs. 500 (597 reputation)Mr or Mrs. 500 (597 reputation)

Group: General Forum Members
Points: 597 Visits: 27695
Nakul Vachhrajani (4/13/2011)
Duncan Pryde (4/13/2011)
Nakul Vachhrajani (4/13/2011)
Thank-you, Duncan for this wonderful series!


You're welcome - although I'd hesitate to call 2 questions a series! Unless you're expecting more? Blink


Definitely expecting more :-) Maybe I like them because a few years ago, we made major changes to our product to support globalization/internationalization and came across all these issues then. These QotDs are great learning opportunities for anyone who would want to work on a product that would work no matter where you take it.



Thank you for these questions Duncan! And I am also expecting more :-).

Cheers
DugyC
DugyC
Ten Centuries
Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)

Group: General Forum Members
Points: 1324 Visits: 779
Great question perfectly worded. It was quite clear that dateformat was relevant to the question and that you were looking for only the 2 statements that would work under all conditions. I hate the pedantics on here.

However, without 2008 to play on, and after much unsuccessful digging around with google, I ended up guessing wrong. Bummer!

Learned something new though, which is always the primary objective :-)

Keep them coming Duncan.

_____________________________________________________________________
"The difficult tasks we do immediately, the impossible takes a little longer"
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