Data conversion

  • Let's please keep this professional. There's no need for name calling.

    I have learned the hard way that the US system for dates is not applicable or appropriate worldwide. I missed the date coding as well, since I am used to the American way, which is ambiguous.

    My apologies for that. I will look to reformat the question and award back points.

  • Ryan Fitzgerald (3/18/2011)


    Bull, theres a comma at the end of the create. That will fail.

    Try running it. I thought it would fail, but I decided to test the code and see what happened. To my surprise, it runs correctly - so I learned something new.

    -Ki

  • Wow, would never have expected that. Guess I learned something new today. Cool!

    Thanks Everyone!

  • Hugo Kornelis (3/18/2011)


    bitbucket-25253 (3/18/2011)


    THANKS FOR CALLING ME STUPID. YOUR ARROGANCE OR SHOULD I SAY EGOTISM IS APPALLING.

    Hmmm. Are you now implying that your use of a non-universal date format was not cause by ignorance, but a deliberate attempt to trick non-Americans in giving the wrong answer? I thought better of you. But in that case, I have to apologize for the word stupid - describing how I feel about deliberately using US-only dates and omittiing the correct answer needs a completely different set of words.

    If it was ignorance, not malice, then sorry if my words offended you. I didn't mean to offend. I did mean to place a firm wake-up call to all the people (in my experience almost always Americans) who all too often forget that there are more countries in the world. That kind of ignorance has, in my opinion, no place in the 21st century world.

    When I started writing this reply, no less than 10 people had already commented in one way or another on the date format issue. You only responded to me, and in your response you only addressed a word that offended you, and one of my typos. I don't mind if you ignore me, but are you at least planning to address the concerns of those other 9 people?

    Mr Hugo Kornelis please accept my apologies for my rant ... it was most unprofessional of me .... if we were close enough I would suggest we shake hands and let bygones be bygones and start afresh.

    If everything seems to be going well, you have obviously overlooked something.

    Ron

    Please help us, help you -before posting a question please read[/url]
    Before posting a performance problem please read[/url]

  • Hugo Kornelis (3/18/2011)


    When will people ever learn about date formats?

    The correct answer ("depends on the locale settings") was not listed, so I had to throw a coin to choose between theory a (question submitted by a stupid American or Japanese who thinks the US/Jap system is the only system) or theory b (question submitted by a stupic non-American/non-Japanese who thinks THEIR system is the only system).

    Note to anyone who ever intends to submit questions with hardcoded dates in them: please use the yyyymmdd format only! Or, if you need time as well, yyyy-mm-ddThh:mm:ss.

    If you really want to tick people off by using a different date format, then FIRST run your code with a SET LANGUAGE statement in front of it, trying all the major languages - then consider if you still want to keep your code that way.

    Hugo,

    I really resent your use of stupid. Whom does the rest of the world turn to when they need help? Whom does the world turn to for leadership? Mostly it's the U.S. So, get off your high horse. And, to include the Japanese as stupid during their time of crisis is horrible.

    I await your apology, though, I don't know that I'd accept it.

  • Steve Jones - SSC Editor (3/18/2011)


    Let's please keep this professional. There's no need for name calling.

    I have learned the hard way that the US system for dates is not applicable or appropriate worldwide. I missed the date coding as well, since I am used to the American way, which is ambiguous.

    My apologies for that. I will look to reformat the question and award back points.

    Who threw the first punch? I think Hugo should apologize. Sorry, Steve, but when someone who is supposed to be respected member of the SQL community, and and MVP, he.she ought to not call entire nations stupid. I can not sit by and let that go.

  • And so I keep coming back to this forum as one of the few where misunderstandings get smoothed over by professionals of many nationalities. Well done. 🙂

    As to locales, what percentage of SQL uses EN-US? Anyone? Just curious, as I, too, tend to be one of those Americans that does not often think about other locales, unless I am on a project that requires it. This is one of those normal human nature things that, as DBA's and IT professionals in general, we need to constantly guard against. As a design architect, I have to remember to ask certain questions EVERY time I meet a new customer and to throw all assumptions out. That's one reason I love questions like this, because it reminds us of those things we should never assume that WILL come back to bite us.

    Assume nothing... unless you have no choice 😉

    Peter Trast
    Microsoft Certified ...(insert many literal strings here)
    Microsoft Design Architect with Alexander Open Systems

  • I don't mind if you ignore me, but are you at least planning to address the concerns of those other 9 people?

    I relied on http://support.microsoft.com/kb/173907

    which states:

    By default, the date format for SQL server is in U.S. date format MM/DD/YY, unless a localized version of SQL Server has been installed

    The item goes on to say how that default value can be altered. I thus assumed (and yes I know assumed means make an a$$ out of you and me). The question does NOT state that a localized version was utilized. If a localized version was installed I again assumed that the user would be aware of this and adjust his/her answer to one using the default date format.

    If everything seems to be going well, you have obviously overlooked something.

    Ron

    Please help us, help you -before posting a question please read[/url]
    Before posting a performance problem please read[/url]

  • bitbucket-25253 (3/18/2011)


    Mr Hugo Kornelis please accept my apologies for my rant ... it was most unprofessional of me .... if we were close enough I would suggest we shake hands and let bygones be bygones and start afresh.

    Accepted. And if we were indeed close enough, I'd immediately buy you a beer.

    Maybe some day at PASS?

    OCTom (3/18/2011)


    I await your apology, though, I don't know that I'd accept it.

    Why ask ... no, demand, ... something you don't want to accept?

    I have to bite my tongue to not react to your political rant about the position of the USA in the world, but this is a SQL Server forum, not a place to discuss politics.

    OCTom (3/18/2011)


    he.she ought to not call entire nations stupid.

    I suggest that you go back and re-read what I wrote. I never called a nation anything. I called certain people of certain nationalities something - and only those people that expose certain behaviour.

    But thinking this over, I now realize that I was out of line. I should not have called these people stupid, just because they expose stupid behaviour. I should have limited myself to labelling their behaviour as ignorant and stupid.

    Peter Trast (3/18/2011)


    As to locales, what percentage of SQL uses EN-US?

    I don't know, but I can share some thoughts.

    I live in the Netherlands. There is no Dutch version of SQL Server, since all Dutch developers have a decent command of the English language anyway. The market is too small for a localized version, and the lack of one is a problem for nobody. How many Dutch SQL Server instances are running with a default language setting of Dutch, I don't know.

    But our neighbor country, Germany, is a different story. There are German versions of virtually everything, including SQL Server. As a result, German developers are much more used to work in their native language. Plus, I assume that in Germany, acquiring an English verion of SQL Server is harder than buying a German version. I expect that the majorit of SQL Server instances in Germany are German.

    And I guess the story is similar for all other major languages - Italian, Spanish, Japanese, Chinese, Russian, Arabic - to name a few.

    What I don't know (but would like to know) is if there are any conditions where British English becomes the default. Maybe one of out British colleagues can shed some light here?

    bitbucket-25253 (3/18/2011)


    I relied on http://support.microsoft.com/kb/173907

    which states:

    By default, the date format for SQL server is in U.S. date format MM/DD/YY, unless a localized version of SQL Server has been installed

    The item goes on to say how that default value can be altered. I thus assumed (and yes I know assumed means make an a$$ out of you and me). The question does NOT state that a localized version was utilized. If a localized version was installed I again assumed that the user would be aware of this and adjust his/her answer to one using the default date format.

    Thanks for taking the time to explain where this misunderstanding comes from, Ron!

    I don't really think that the problem is in people not being able to adjust an answer to their own default format; the problem I saw is that I don't know YOUR default format - I had to assume whether you ran on US settings (in which case the date would convert okay), or on GB settings (in which case the correct answer would be that the insert fails).


    Hugo Kornelis, SQL Server/Data Platform MVP (2006-2016)
    Visit my SQL Server blog: https://sqlserverfast.com/blog/
    SQL Server Execution Plan Reference: https://sqlserverfast.com/epr/

  • Hugo Kornelis Posted Today @ 3:06 PM

    Accepted. And if we were indeed close enough, I'd immediately buy you a beer.

    Maybe some day at PASS?

    The good lord willing that beer will be accepted, under one (1) condition, and that is, I can also buy you one.

    Now calculate the odds on us meeting - please read my profile, in particular the personal information.

    If everything seems to be going well, you have obviously overlooked something.

    Ron

    Please help us, help you -before posting a question please read[/url]
    Before posting a performance problem please read[/url]

  • thanks for the question.

    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

  • It fails for me (unless I retyped it wrong)

    create table #Money

    (ID INT IDENTITY(1,1) PRIMARY KEY CLUSTERED,

    Date DATETIME

    AMOUNT INT,)

    SET IDENTITY_INSERT #Money ON

    INSERT INTO #Money(ID, Date, Amount)

    SELECT '1', ' 2/10/2010 ', '12' UNION ALL

    SELECT '2', ' 2/11/2010 ', '13' UNION ALL

    SELECT '3', ' 2/12/2010 ', '14' UNION ALL

    SELECT '4', ' 2/13/2010 ', '15' UNION

    select sum(AMOUNT) FROM #Money

    I get an incorrect syntax near 'AMOUNT' msg.

  • John Hanrahan (3/18/2011)


    It fails for me (unless I retyped it wrong)

    create table #Money

    (ID INT IDENTITY(1,1) PRIMARY KEY CLUSTERED,

    Date DATETIME

    AMOUNT INT,)

    SET IDENTITY_INSERT #Money ON

    INSERT INTO #Money(ID, Date, Amount)

    SELECT '1', ' 2/10/2010 ', '12' UNION ALL

    SELECT '2', ' 2/11/2010 ', '13' UNION ALL

    SELECT '3', ' 2/12/2010 ', '14' UNION ALL

    SELECT '4', ' 2/13/2010 ', '15' UNION

    select sum(AMOUNT) FROM #Money

    I get an incorrect syntax near 'AMOUNT' msg.

    You missed the comma after DATETIME in the CREATE TABLE statement:

    create table #Money

    (ID INT IDENTITY(1,1) PRIMARY KEY CLUSTERED,

    Date DATETIME,

    AMOUNT INT,)

    SET IDENTITY_INSERT #Money ON

    INSERT INTO #Money(ID, Date, Amount)

    SELECT '1', ' 2/10/2010 ', '12' UNION ALL

    SELECT '2', ' 2/11/2010 ', '13' UNION ALL

    SELECT '3', ' 2/12/2010 ', '14' UNION ALL

    SELECT '4', ' 2/13/2010 ', '15' UNION

    select sum(AMOUNT) FROM #Money

  • Did not get it right :(, got tricked by the extra comma after the last column. Had it not been for the extra comma i would have answered it right. Nevertheless a good question!

    Amol Naik

  • Well, that was an interesting question, not for the question itself (I don't know SQL enough to have seen any thing that would have not making it worked, so I got the answer wright by my ignorance :-P), but by the lecture of the comments of the people about the world, then making peace...and my comment on this would be: "Stupid is as stupid does" (Forest Gump)

    I love all guys!:kiss:

    Thanks for the question!

Viewing 15 posts - 46 through 60 (of 101 total)

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