Basic Date Function

  • crmitchell (2/15/2013)


    L' Eomot Inversé (2/15/2013)


    What worries me there is that - even with the very appropriate emoticon - the person to whom you replied may be insufficiently awake to detect your sarcasm. But I still wish I could have gotten in first with a response like yours :exclamationmark: 😀

    I noticed it several hours ago but as it just supported my point didn't feel it needed a response.

    Tom, you were right!

    the client and server that the user is using are set to different timezones from each other and that the country settings of the server does not match the default for that time zone.

    There is nothing in the question that implies any of this.

    That that timezone is different from my own generally is irrelevant.

    You are correct!

    Although in this case as my timezone is GMT which is for practical purposes the same as UTC it opens up the possibility that two of the answers will in that particular situation generate the same result.

    You mean in that particular situation which isn't the one implied by the question...

    Joey is a Budgie

    Yes, I think he probably is.

  • sipas (2/15/2013)


    crmitchell (2/15/2013)


    L' Eomot Inversé (2/15/2013)


    What worries me there is that - even with the very appropriate emoticon - the person to whom you replied may be insufficiently awake to detect your sarcasm. But I still wish I could have gotten in first with a response like yours :exclamationmark: 😀

    the client and server that the user is using are set to different timezones from each other and that the country settings of the server does not match the default for that time zone.

    There is nothing in the question that implies any of this.

    .

    And that is the problem. If you think that try carrying out the query at that time on a set of client and server set to any other time offset and see if you get the expected result.

    The date format given is US specific. - Implied by the question

    The time returned by the server being offset implies the two boxes are set to different times - again implied by the question.

    That the date format does not match the default format for those countries offset from the US time zones also implies the last part.

  • crmitchell (2/15/2013)


    The time returned by the server being offset implies the two boxes are set to different times

    But what implies there are two boxes?

    I can tell you're not gong to be convinced(!), but just so others are clear, I think this is what you should take away from the question - to quote BOL:

    SYSDATETIME returns the date and time of the computer on which the instance of SQL Server is running

    SYSUTCDATETIME returns the date and time of the computer on which the instance of SQL Server is running. The date and time is returned as UTC time (Coordinated Universal Time).

    Therefore, on the computer on which the instance of SQL Server is running, if the system date and time is not UTC, SYSUTCDATETIME will return a different date and time to the system date and time. There is only one computer involved.

    A question about two computers set to different timezones is a completely different question, possibly an interesting question, but not this question.

  • +1

    Yeah, timezones.

    There is one time! that is NOW().

  • sipas (2/15/2013)


    But what implies there are two boxes?

    Nothing.

    What suggests there is only one?

    Nothing.

    Either requires an assumption.

  • +1. Nice question.

  • Yet another question that deserves to be removed along with all associated points (or lack thereof), as this is clearly dependent on not only WHEN you answer the question, but WHERE you happen to be in the world at the time. I "incorrectly" assumed that the composer would take that into account, and that therefore, such a bias wouldn't make it into a question, and that therefore the answer SYSDATETIME() was good enough based on format alone. While I "discovered" that SYSUTCDATETIME() also uses the same format, that's hardly useful information, given that I won't be using it for any reason from where I'm located. Please consider the value of the question before deciding it's a good one.

  • sgmunson (3/13/2013)


    Please consider the value of the question before deciding it's a good one.

    Please consider the value of your reply before adding the thousandth identical "this question is wrong" post 😉

  • Hugo Kornelis (2/13/2013)


    I had almost missed the different time in the returned output, as I was focusing completely on the data type. Caught is just in time!

    I do not agree with some of the comments here that time zone of the computer was required to answer this. Once I saw that the time portion of the result was not the same as the listed system time, there was only one option left anyway.

    +1

    I got it right with time part...

  • why not CURRENT_TIMESTAMP??

    Thanks.

Viewing 10 posts - 46 through 55 (of 55 total)

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