Dating for DBAs - a second date

  • CirquedeSQLeil (4/13/2011)


    paul.knibbs (4/13/2011)


    Oh, I agree, the question was perfectly clear--... 😀

    I agree - I felt the question was very precise and clear in the meaning and intent.

    Me too.

    It's unfortunate that QotD is unlikely to teach reading comprehension, which has clearly been lacking rather a lot judging by the number of responses that claim all four work.

    Tom

  • 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:

    I think the awesome title choice gives it that "series" feel.

    Nice question, I just need to pay more attention to the "select 2" part next time.

  • Hi Duncan

    About a week ago, you asked just about the same question, with the same words (choices was different) and the language was part of the answer... I should have got this one right... but I did not. I did not think. It was too easy! I knew that all fourth would work on my machine! ... did not think about the language at all... I should remember now! Thanks for the good question!

  • Cliff Jones (4/13/2011)


    A very good question. It is unfortunate that some are not getting the message that it is trying to convey, that not all date formats are portable across all language settings. If you ever have to port your application to a different country or language, this can cause a lot of rework.

    It's slightly disappointing that the percentage of right answers is almost exactly the same as last week, but then it often takes a while for new concepts to sink in. Despite being in the UK, most of the servers we deal with are installed with US_English as the default language. I reckon it was several years before people (including me) noticed that the 'yyyy-MM-dd' format didn't work in "British", and I vaguely remember trying to debug an application that used the format and had stopped working when the database was moved to another server. It took ages to work out what the problem was, but once we had, the mistake was never made again!

  • rmechaber (4/13/2011)


    Duncan, nice follow-up to your last question. I'm gratified? relieved? to see so many wrong answers, as I thought everyone else but me knew what Tibor Karaszi pointed out in his blog: SQL Server DATETIME and SMALLDATETIME types are not ANSI-compliant.

    As a follow-up to this issue, I was quite surprised to learn that (apparently), unless you have purchased and installed a local version of SQL Server, you cannot change the language settings at the server level, only for individual logins or query sessions. (You apparently can issue the command without error, but it makes no difference.) It may be possible to make a registry change to force the language change; see http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=62891.

    I cannot find official confirmation of this behavior at Microsoft, but here's a relevant article excerpt from http://www.sqlservercurry.com/2010/11/change-default-language-for-sql-server.html

    If you have not installed the localized version of SQL Server, the default language is US English. If you need to change the default language on this machine, then you will have to change the default language for individual logins, as doing it on a server level won't work.

    Thanks again for great questions,

    Rich

    You can't change the installation language (whatever that means) but you can change the server default language. I did that myself recently, I think following that discussion in which you first posted the Tibor Karaszi link. Once you change the language, all subsequently created logins will use the new default language, but all existing logins will use the previous default language, or whatever language they were created with.

  • 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[/url]
    For tips on how to post your problems[/url]

  • 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/MCSE/MCSA

  • All 4 work on my SQL 2008.

    bogus question...

    Dennis Parks
    MCSE, MCDBA, MCSD, MCAD, MCTS

  • 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.

  • 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

  • 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?'.

  • ok, then I guess it tricked me. :~)

    Dennis Parks
    MCSE, MCDBA, MCSD, MCAD, MCTS

  • Something is wrong with that answer provided.

  • Mr Quillz (5/13/2011)


    Something is wrong with that answer provided.

    No, there isn't. Try reading the rest of the thread.

Viewing 14 posts - 46 through 58 (of 58 total)

You must be logged in to reply to this topic. Login to reply