T-SQL

  • I do agree with Wayne, Answer should be false only.

  • A good example of the need for thorough testing ๐Ÿ™‚ Would rather not have a mark against me on the stats for answering correctly though ๐Ÿ™

  • This one was really bad. I knew something was up when I saw it was worth 3 points. I selected False like everyone else in the forum and was smiling when I submitted my answer expecting to see a "You got it right" message.

    Was shocked to see that I got it wrong. I tested it like everyone else and the results are not the same even when run in a batch.

  • I actually answered true, and here is why, if you run this:

    select getdate(), getutcdate()

    you may get a result like this:

    2009-11-17 06:16:57.527 2009-11-17 13:16:57.527

    They appear different, but are actually the same. The first is the local time, the second is the same time as UTC. It is generated from the same system clock and adjusted based on the time zone.

  • I think getdate() = getutcdate() would return false in your time zone, so I think they're probably different!

  • I thought the most active Forum Creators must have tested before putting it in the Question of the Day Section.

    The Answer should be false. For those who reside in country which are not following UTC time will have different results.

    I have seen such questions more than once.

    Was it taken to be granted that we live in UK????

    Hiren

    Hiren Shah

    :kiss:KISS (Keep It Simple Stupid) :kiss:

  • Thought about answering True, because for me (in the UK) they will return the same value, but figured that the author was probably in the US so the answer was therefore False. Wrong assumption!

    I guess there should be a list of assumptions already mentioned.

    The author resides in UK. Kindly follow his time. The author is unaware about the difference between getdate() and getutcdate().

    Hiren Shah

    :kiss:KISS (Keep It Simple Stupid) :kiss:

  • I would guess this was 3 points because the site admins expected everyone to get it wrong unless you took the time to translate your local time into UTC time. Translating to UTC, the results do all theoretically match. I like everyone else, answered false because I took the question literally as "do these all return the same date, hour. minute and second?" And for me they did not.

  • Lynn Pettis (11/17/2009)


    I actually answered true, and here is why, if you run this:

    select getdate(), getutcdate()

    you may get a result like this:

    2009-11-17 06:16:57.527 2009-11-17 13:16:57.527

    They appear different, but are actually the same. The first is the local time, the second is the same time as UTC. It is generated from the same system clock and adjusted based on the time zone.

    Even with the adjustment for the time zone, the answer should be false, becuase the question was divided into four select statements, and the second may already have changed between the statements. In your case, you will get the same second because it is in the same statement.

    /Hรฅkan Winther
    MCITP:Database Developer 2008
    MCTS: SQL Server 2008, Implementation and Maintenance
    MCSE: Data Platform

  • david.wright-948385 (11/17/2009)


    I think getdate() = getutcdate() would return false in your time zone, so I think they're probably different!

    Everyone is looking at the values, yes, they are "different", but both represent the same time. One is local, the other UTC.

  • Also, I think bitbucket resides somewhere on the east coast of the USA, not in the UK.

  • Lynn Pettis (11/17/2009)


    Everyone is looking at the values, yes, they are "different", but both represent the same time. One is local, the other UTC.

    If that is the reasoning then it's a poor question as it relies on a very pedantic interpretation of the English language. As a native English speaker I'd say the exact meaning is debatable (to put it charitably), so those for whom it's a second (or third) language don't stand a chance!

  • Lynn, you have a valid point but if you were to show those times to a client, they would only see the output not the representation. So, for example, if someone wanted a report pulled that showed "clock in times" and I showed that time in UTC, they would freak out thinking the report is wrong and I would have to agree with them.

  • I think you must define what is the goal of the question.

    as a plain English the question is clear, and you are asking for a specific result: an instance (defined value) of date, hour , minute.

    my choice was false, and in my opinion is the correct answer; you have to formulate correctly your question.

  • Lynn Pettis (11/17/2009)


    I actually answered true, and here is why, if you run this:

    select getdate(), getutcdate()

    you may get a result like this:

    2009-11-17 06:16:57.527 2009-11-17 13:16:57.527

    They appear different, but are actually the same. The first is the local time, the second is the same time as UTC. It is generated from the same system clock and adjusted based on the time zone.

    True, the values originated from the internal system clock. However, once converted into the resulting target values they are different (except where the system's time zone setting is the same as UTC). All time zone metadata is lost once the values have been computed and displayed. If you were to store the resulting values in two different database columns the values would never compare as equal.

    Now if the question referenced the new SQL Server 2008 data type of DATETIMEOFFSET, where the time zone is part of the resuting value, then the answer would be True.

    Without the timezone metadata, the resulting values are just strings of characters.


    [font="Arial Narrow"](PHB) I think we should build an SQL database. (Dilbert) What color do you want that database? (PHB) I think mauve has the most RAM.[/font]

Viewing 15 posts - 16 through 30 (of 203 total)

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