T-SQL

  • Comments posted to this topic are about the item T-SQL

    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]

  • When I run the four statements, I get:

    2009-11-15 22:39:14.090 Sunday

    2009-11-15 22:39:14.090 Sunday

    2009-11-16 03:39:14.090 Monday

    2009-11-16 03:39:14.090 Monday

    Not the same day or hour. They're not returning the same values.

    Wayne
    Microsoft Certified Master: SQL Server 2008
    Author - SQL Server T-SQL Recipes


    If you can't explain to another person how the code that you're copying from the internet works, then DON'T USE IT on a production system! After all, you will be the one supporting it!
    Links:
    For better assistance in answering your questions
    Performance Problems
    Common date/time routines
    Understanding and Using APPLY Part 1 & Part 2

  • the answer should be false because until unless ur on the same timezone as utc the day and hour will vary .

  • This was removed by the editor as SPAM

  • The answer should be false. how come getdate() and getutcdate() will return the same value

  • The answer should be false. how come getdate() and getutcdate() will return the same value

  • If the UTC time is marked as UTC then I would say TRUE otherwise FALSE.

  • Check http://msdn.microsoft.com/en-us/library/ms188383.aspx :w00t:

    BTW: correct link for GetDate to this, there are double DateAdd links

    Examples

    The following examples use the six SQL Server system functions that return current date and time to return the date, time, or both. The values are returned in series; therefore, their fractional seconds might be different.

    A. Getting the current system date and time

    SELECT SYSDATETIME()

    ,SYSDATETIMEOFFSET()

    ,SYSUTCDATETIME()

    ,CURRENT_TIMESTAMP

    ,GETDATE()

    ,GETUTCDATE();

    Here is the result set.

    SYSDATETIME() 2007-04-30 13:10:02.0474381

    SYSDATETIMEOFFSET()2007-04-30 13:10:02.0474381 -07:00

    SYSUTCDATETIME() 2007-04-30 20:10:02.0474381

    CURRENT_TIMESTAMP 2007-04-30 13:10:02.047

    GETDATE() 2007-04-30 13:10:02.047

    GETUTCDATE() 2007-04-30 20:10:02.047

    Do you find GETDATE and GETUTCDATE results the same :blink:

    Check getutcdate Example A ➑ same story

    Not all of us reside in UK time zone :crazy:

  • rene-500237 (11/17/2009)


    If the UTC time is marked as UTC then I would say TRUE otherwise FALSE.

    I agree, everyone does not live in GMT zone or install our OS with GMT zone. πŸ™‚

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

  • So, I answered correct but false. Who will apologize to me ? πŸ˜‰

  • Correct answer should be FALSE, because i received next results:

    2009-11-16 10:50:43.533

    2009-11-16 10:50:43.533

    2009-11-16 08:50:43.533

    2009-11-16 08:50:43.533

    I'm living in Ukraine and our Timezone = +2 Hours.

    Please, accept my answer as correct. Thanks.

  • 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!

  • Same for me. Not only that but depending on exactly WHEN you run this you may well be different seconds, given that getdate() etc will be called in 4 different calls. Ok, so that was only the difference between .393 and .403 on the ms, but if that happened at a second boundary then that would change the seconds value.

    So all in all, wrong on so many levels.

  • Nice question: so, we could see the time zone of every user. πŸ˜€

    I live in Italy +1 hour.

    2009-11-16 11:42:01.793Monday

    2009-11-16 11:42:01.793Monday

    2009-11-16 10:42:01.793Monday

    2009-11-16 10:42:01.793Monday

    Ciao Ciao

  • The answer should be false.

    When I run the four statements, I get:

    2009-11-16 16:38:22.217Monday

    2009-11-16 16:38:22.217Monday

    2009-11-16 11:08:22.217Monday

    2009-11-16 11:08:22.217Monday

    Here time and minutes are different.

Viewing 15 posts - 1 through 15 (of 203 total)

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