• kramaswamy (10/31/2012)


    Hi all,

    What I discovered eventually is that there are times where GETDATE() and GETUTCDATE(), executed on the same row of the query, occasionally return different results:

    GETDATE() : 2012-10-31 13:58:48.933

    GETUTCDATE() : 2012-10-31 17:58:48.940

    As you can see, there is a 0.07 milisecond difference in those two values. What this means is that when I take my function above and run it, instead of getting a 4-hour time offset, I get a 5-hour time offset, which completely messes up the results.

    You should expect them to return different values - it takes time to execute a function call and these are executed serially.

    If you need them to represent the same time you need to extract the time into a variable first and then operate on that variable rather than sequentially calling functions to get dates.