T-SQL

  • rparakalla (11/18/2009)


    Lynn Pettis (11/18/2009)


    rparakalla (11/18/2009)


    Yes I would also agree. The names may be different but refer to the same person. So they are equivalent. But the output of getdate() and getutcdate() is different. getutcdate doesn't specify if it is GMT/local time while comparing to the output of getdate(). If you say is '1/1/2009' same or equivalent to 'Jan 1 2009' then it is YES. But Is 'Jan 1 2009 00:00:00' same or equivalent to 'Jan 1 2009 05:30:30' then its NO, in my opinion.

    If you aren't told that one time is local and the other UTC, I'd agree. Based on the question asked, however, you DO KNOW one is local and one is UTC. In an actual production application, you'd expect that the variable names or column names would also indicate that, and if not, the data dictionary that provides you with the details of each column should provide that detail to you.

    Yes, that is what has caused all the confusion. Just from the query you know that it is getdate() representing local datetime and getutcdate() representing GMT datetime. But not from the output if we run the code:

    declare @d datetime, @U datetime

    select @d = getdate(), @U = getutcdate()

    SELECT DATEADD(day, -1, @d),DATENAME (dw ,DATEADD(day, -1, @d) )

    SELECT @d - 1, DATENAME (dw ,@d - 1)

    SELECT @U - 1, DATENAME (dw,@u - 1)

    SELECT DATEADD(day, -1, @U), DATENAME (dw,DATEADD(day, -1, @U))

    GO

    The general tendency is to compare the results and not the system function names I guess.

    How do you compare the results if you don't have an understanding of how they are generated? To compare something, you have to understand (know, comprehend) what you are working with.

  • Lynn Pettis (11/18/2009)

    How do you compare the results if you don't have an understanding of how they are generated? To compare something, you have to understand (know, comprehend) what you are working with.

    Then the question should have been put simply something like this instead of so much mayhem:

    Does the getdate() and getutcdate() functions represent same datetime.

  • Mayhem? I didn't see any mayhem. Lots of disgruntled posts, yes. I learned quite a bit from the discussion that ensued, some of it not directly related to the question. It is from the discussion that true learning can occur, not from just answering a question and reading the explaination.

  • Bold emphasis entered by this poster.

    Lynn Pettis

    I learned quite a bit from the discussion that ensued, some of it not directly related to the question. It is from the discussion that true learning can occur, not from just answering a question and reading the explaination.

    In support of Lynn, and one of the objectives of the QOD:

    Kevin C. Posted Today @ 2:19 PM

    Thank you Bitbucket for the excellent QoD.

    Thank you everyone else for your excellent view points and comments.

    I have learned much today not just about datetime and the two functions (getdate(), getutcdate()) but I also learned more about batches and timing issues and how small changes can end up causing relatively large differences.

    Thanks all.

    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]

  • Well BitBucket, I trust you have learnt to ask questions in a more straightforward manner.

    I'm tired of playing the qod game with questions like this. I want to be tested on SQL, not on smarmy tricky questions that depend on a particular local syntax of english.

    What I'm learning is that the questions can't be trusted.

    ---

    The values are NOT equivalent.

    The point-in-time represented is the same, but without adding time-zone information to the output they are different.

    David Todd

  • Speaking of time, that was a really really good question because it brought me back 30 years ago while I was in school and the professor had to pick up the best of the best with trick question :w00t:

    Was fun to read you all!

    Thanks!

    Oh, by the way, I got it wrong too. Never got picked in those time, so won't change now!:laugh:

  • Well like most of the people on this forum I selected false as the values are not the same.

    Well I suippose if you were planning the simultaneous worldwide release of a movie like "This is it", then I suppose you would use the GetUTCDate to ensure that all points in time are the same.

    However these kind of tricky question are ridiculous. They assume that all members of the site speak perfect English and understand the subtle nuances in the phrasing of a question. You would think the essence is knowledge on SQL Server and not on English.

    Getting tired of word plays.

  • Karin.Nooteboom-1039448 (11/19/2009)


    However these kind of tricky question are ridiculous. They assume that all members of the site speak perfect English and understand the subtle nuances in the phrasing of a question. You would think the essence is knowledge on SQL Server and not on English.

    Getting tired of word plays.

    What about writing some QOD in our native languages?

    I am Czech (and if needed I can write in several dialects, autoamatic translators will be very unhappy).

    😀

    Some contributors are from countries that use other alphabets. I can read russian, but understand technical information, it's not so easy. Not speaking about China, Arabia...

    Just for fun: ???? ????

    Try to discover, what does it mean.



    See, understand, learn, try, use efficient
    © Dr.Plch

  • I must say that the defence of the question/answer by bitbucket and Lynn Pettis is far from convincing.

    And I am in the GMT time-zone!

    It seems to be you two against the rest of the world.

    What was the point that the question was trying to demonstrate?

    Martin

  • honza.mf (11/19/2009)


    Karin.Nooteboom-1039448 (11/19/2009)


    Just for fun: ???? ????

    Try to discover, what does it mean.

    According to Google Translate, it means: Foucault

    Don't know what that means but when I look it up in an English dictionary:

    Foucault is a small lunar impact crater that lies along the southern edge of Mare Frigoris, to the southeast of the crater Harpalus

  • cengland0 (11/19/2009)


    honza.mf (11/19/2009)



    Just for fun: ???? ????

    Try to discover, what does it mean.

    According to Google Translate, it means: Foucault

    Don't know what that means but when I look it up in an English dictionary:

    Foucault is a small lunar impact crater that lies along the southern edge of Mare Frigoris, to the southeast of the crater Harpalus

    🙂

    Try Google itself. One of the first links leads to ?????????, use English on the left side.

    Translator ommited the first word. To tell the truth, the more simple to translate, as it is a common word, not the transliteration of the name.

    The reason I like this term is, it resembles me a spell. First time I've seen it, I had to read at least the beggining of an article, to understand.



    See, understand, learn, try, use efficient
    © Dr.Plch

  • honza.mf (11/19/2009)


    Try Google itself. One of the first links leads to ?????????, use English on the left side.

    Translator ommited the first word. To tell the truth, the more simple to translate, as it is a common word, not the transliteration of the name.

    The reason I like this term is, it resembles me a spell. First time I've seen it, I had to read at least the beggining of an article, to understand.

    So it's Eddie Currents? That's not really a common term.

  • cengland0 (11/19/2009)


    honza.mf (11/19/2009)


    Try Google itself. One of the first links leads to ?????????, use English on the left side.

    Translator ommited the first word. To tell the truth, the more simple to translate, as it is a common word, not the transliteration of the name.

    The reason I like this term is, it resembles me a spell. First time I've seen it, I had to read at least the beggining of an article, to understand.

    So it's Eddie Currents? That's not really a common term.

    Searching common terms is funny? Not for me 🙂

    I just wanted to show how a transliteration can change the visual form of the words. I think my name writen in katakana will resemble nothing to me.



    See, understand, learn, try, use efficient
    © Dr.Plch

  • David Todd-242471

    Well BitBucket, .

    I'm tired of playing the qod game with questions like this. I want to be tested on SQL, not on smarmy tricky questions that depend on a particular local syntax of english.

    What I'm learning is that the questions can't be trusted.

    David Todd-242471 - The question was designed to test the readers knowledge of a group of SQL functions relating to time, and understanding of a point in time. To determine if the individual truly understood that they all returned the same point in time, as so well put by Karin.Nooteboom-1039448 (Quoted below). Your

    I trust you have learnt to ask questions in a more straightforward manner

    I think implies that you prefer questions that require little or no thinking, those that can be cut and pasted into SSMS to obtain the answer.

    honza.mf

    ???? ????

    - Russian - in english Foucault (given the name of its discoverer who was a physicist (1819-1868):

    "Is a closed electrical eddy currents in massive conductor, which arise when changing the magnetic flux penetrating it." Not at all difficult to translate or understand.

    Martin Wills

    What was the point that the question was trying to demonstrate?

    Karin.Nooteboom I thank your for so eloquently answering Martin Wills.

    Karin.Nooteboom-1039448

    Well I suppose if you were planning the simultaneous worldwide release of a movie like "This is it", then I suppose you would use the GetUTCDate to ensure that all points in time are the same.

    Substitute "Receipt of an order for goods or services as recorded in a international corporations dB" for "release of a movie " and it makes it less difficult to relate to this discussion.

    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]

  • David Todd-242471 (11/18/2009)


    The values are NOT equivalent.

    The point-in-time represented is the same, but without adding time-zone information to the output they are different.

    David Todd

    Forget the question for a bit. If the columns or variables are properly named and/or documented to allow the developer to know what data is stored in them (local or UTC), then yes they are equivalent as they represent the same point in time. As how they are displayed, that is up to the developer in UI to ensure that occurs.

Viewing 15 posts - 166 through 180 (of 203 total)

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