• Kingston Dhasian (2/18/2013)


    Jeff Moden (2/15/2013)


    I suppose consistency is a good reason. But, let's try something just for fun. Write some code to add 41:41:41.041 to a given date.

    My version

    DECLARE@date DATETIME

    SET@date = CURRENT_TIMESTAMP

    SELECT @date AS Date, DATEADD(MILLISECOND, 41, DATEADD(SECOND, 41, DATEADD(MINUTE, 41, DATEADD(HOUR, 41, @date)))) AS Date_Added

    I get the output as below

    Date Date_Added

    2013-02-18 10:29:50.343 2013-02-20 04:11:31.383

    The only strange thing I observed is that it always 40 milliseconds instead of 41 milliseconds.

    Is there any other strange thing?

    I'll try to get back to this after worrk tonight. In the mean time, remember that DATETIME has an accuracty of only 3.3 milliseconds. All DATETIMES will end with 0, 3, or 7 for the final digit in the milliseconds.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)