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


    Kingston Dhasian

    How to post data/code on a forum to get the best help - Jeff Moden
    http://www.sqlservercentral.com/articles/Best+Practices/61537/