T-SQL

  • david.j.campbell (11/17/2009)


    You on the same longitude as Greenwich England, Bitbucket?

    This is the first time I can think of that I've been discriminated against based on my geography.

    While the values may be equivalent, the word SAME and calling out hours minutes and seconds leads one to think of the values returned rather than equivalence.

    No, he isn't.

  • Lynn Pettis (11/17/2009)


    Yes, getdate() and getutcdate() return different values, just look at what they return when you run them. However both functions return values that are equivelent to each other, 8:00 AM MST == 9:00 AM CST == 10:00 AM EST == 3:00 PM UTC.

    But the question asked if they were the same, not if they were equivalent 🙂

  • Toreador (11/17/2009)


    Lynn Pettis (11/17/2009)


    Yes, getdate() and getutcdate() return different values, just look at what they return when you run them. However both functions return values that are equivelent to each other, 8:00 AM MST == 9:00 AM CST == 10:00 AM EST == 3:00 PM UTC.

    But the question asked if they were the same, not if they were equivalent 🙂

    You know, I haven't tried writing a QotD. Have you?

  • BitBucket and Lynn,

    I'll throw my hat in the ring in your favor. I can't argue as eloquently as Lynn, but I'll say this - you are absolutely correct. I'm in the Mountain time zone - while it's 9 AM here, it's 4 PM in Greenwich and that is exactly the same time. :w00t: I admit that I didn't think about it that way until Lynn explained it, but it does make perfect sense. Thanks for helping me think outside the box! (wow... there sure are a lot of unhappy people inside that box - come out and join us, we're having a party! :-P)

    Chad

  • I also answered right as False.

  • Lynn Pettis (11/17/2009)


    You know, I haven't tried writing a QotD. Have you?

    Ah, that old chestnut.

    I've never been Prime Minister either, but I still get to say what I think about our current one 🙂

  • BitBucket and Lynn,

    I'll throw my hat in the ring in your favor. I can't argue as eloquently as Lynn, but I'll say this - you are absolutely correct. I'm in the Mountain time zone - while it's 9 AM here, it's 4 PM in Greenwich and that is exactly the same time. I admit that I didn't think about it that way until Lynn explained it, but it does make perfect sense. Thanks for helping me think outside the box! (wow... there sure are a lot of unhappy people inside that box - come out and join us, we're having a party! )

    Chad

    Emphasis added to the quote by the undersigned.

    Thanks Chad, it makes me feel that the objective of the QOD was fulfilled and the time I put in to compose same was worthwhile.

    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]

  • Lynn Pettis (11/17/2009)


    Toreador (11/17/2009)


    Lynn Pettis (11/17/2009)


    Yes, getdate() and getutcdate() return different values, just look at what they return when you run them. However both functions return values that are equivelent to each other, 8:00 AM MST == 9:00 AM CST == 10:00 AM EST == 3:00 PM UTC.

    But the question asked if they were the same, not if they were equivalent 🙂

    You know, I haven't tried writing a QotD. Have you?

    There's the answer then - we should restrict comments on the veracity of QOD to people who have submitted a QOD themselves.

  • Can the QOD be changed then please? If not to change the answer (which is my preference) then to explain why the answer given is as it is.

  • david.wright-948385

    There's the answer then - we should restrict comments on the veracity of QOD to people who have submitted a QOD themselves.

    No do not think that is appropriate, but as I have challenged others to write a QOD. I found myself gaining knowledge, and would encourage others to attempt a QOD and in so doing increase their own knowledge of T-SQL and databases.

    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]

  • Good question BitBucket. Since I got it wrong I made a point to research (and also going through the discussion) why I was wrong and so in turn learned more and will probably remember it better than the questions I got right.

    Thanks,

    Supriya

  • Why don't we let T-SQL be the judge:

    SELECT

    'Test1' = CASE

    WHEN DATEADD(day, -1, GETDATE()) = GETDATE() -1 THEN 'TRUE'

    ELSE 'FALSE'

    END,

    'Test2' = CASE

    WHEN DATEADD(day, -1, GETDATE()) = GETUTCDATE() -1 THEN 'TRUE'

    ELSE 'FALSE'

    END,

    'Test3' = CASE

    WHEN DATEADD(day, -1, GETUTCDATE()) = GETUTCDATE() -1 THEN 'TRUE'

    ELSE 'FALSE'

    END,

    'Test4' = CASE

    WHEN GETDATE() -1 = GETUTCDATE() - 1 THEN 'TRUE'

    ELSE 'FALSE'

    END,

    'Test5' = CASE

    WHEN GETDATE() -1 = DATEADD(day, -1, GETUTCDATE()) THEN 'TRUE'

    ELSE 'FALSE'

    END,

    'Test6' = CASE

    WHEN GETUTCDATE() - 1 = DATEADD(day, -1, GETUTCDATE()) THEN 'TRUE'

    ELSE 'FALSE'

    END

    Test1Test2Test3Test4Test5Test6

    TRUEFALSETRUEFALSEFALSETRUE

  • I totally agree with you! When the question says "date", "hour" & "seconds" in particular, the answer is false in true sense.

  • I actually HAVE submitted a QOTD and was trounced for inaccurate wording. In this case, however, the answer to the question asked is FALSE. It's been shown multiple times that the results are not the same and there should be NO expectation that 4 calls to get time from a system would return the same value. Unless the QOTD $deities intervene you won't get your 3 points, a plague will spread over the land, the dead will rise up and the zombies will be hungry for the living.

    Oh wait. It won't? No one is going to die because of a question that didn't consider all the assumptions? Something was wrong on the internet?

    Let's move on, nothing to see here.

  • OK. I'm going to quibble a bit. I, personally, do not consider the same point in time in the mountain time zone in the U.S. to be the same time in Singapore. They are the same point in time but not the same time. So, I answered false, but, does it really matter? It got me thinking about time zones and how they could affect user's perceptions. That's why we used GMT references in the Navy, though we called it zulu. It clears up misperceptions of when something is to occur. When you say the mission starts at 18 hundred zulu, everyone instantly converted that to their local time zone.

Viewing 15 posts - 61 through 75 (of 203 total)

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