DATEADD function

  • bitbucket-25253 (8/11/2012)


    L' Eomot InversΓ© (8/11/2012)


    Nice easy question to start the week with (2 days early).

    I wonder if the 100% correct rate will continue when everyone sees it and starts answering on Monday. πŸ˜€

    Going to hades in a hand basket already

    Correct answers:

    75%

    (6)

    Incorrect answers:

    25%

    (2)

    Total attempts: 8

    563 attempts so far and things got better. Looking at 88% correct now.

    Jason...AKA CirqueDeSQLeil
    _______________________________________________
    I have given a name to my pain...MCM SQL Server, MVP
    SQL RNNR
    Posting Performance Based Questions - Gail Shaw[/url]
    Learn Extended Events

  • But nothing was added...Not complaining though

    What you don't know won't hurt you but what you know will make you plan to know better
  • Great one and thanks for the easy one.

  • BudaCli (8/13/2012)


    But nothing was added...Not complaining though

    Yes there was, 0 (zero) seconds was added to the 0 (zero date, 1900-01-01 00:00:00.000).

  • Amazing command that dateadd having datepart second, month, etc. Need to know what you are doing when you use it...

    From the explanation, it says that:

    If datepart is month and the date month has more days than the return month and the date day does not exist in the return month, the last day of the return month is returned. For example, September has 30 days; therefore, the two following statements return 2006-09-30 00:00:00.000:

    SELECT DATEADD(month, 1, '2006-08-30')

    SELECT DATEADD(month, 1, '2006-08-31')

    Learn something more today!

    Thanks

  • Little behind... Took me until Tuesday...... to get it.... RIGHT. Monday was rough for sure. πŸ˜›

  • tilew-948340 (8/13/2012)


    Amazing command that dateadd having datepart second, month, etc. Need to know what you are doing when you use it...

    From the explanation, it says that:

    If datepart is month and the date month has more days than the return month and the date day does not exist in the return month, the last day of the return month is returned. For example, September has 30 days; therefore, the two following statements return 2006-09-30 00:00:00.000:

    SELECT DATEADD(month, 1, '2006-08-30')

    SELECT DATEADD(month, 1, '2006-08-31')

    Learn something more today!

    Thanks

    very rightly pointed out...DATEADD does not check if the date is a valid date or not πŸ™‚

    ~ Lokesh Vij


    Guidelines for quicker answers on T-SQL question[/url]
    Guidelines for answers on Performance questions

    Link to my Blog Post --> www.SQLPathy.com[/url]

    Follow me @Twitter

  • Lokesh Vij (8/14/2012)


    tilew-948340 (8/13/2012)


    Amazing command that dateadd having datepart second, month, etc. Need to know what you are doing when you use it...

    From the explanation, it says that:

    If datepart is month and the date month has more days than the return month and the date day does not exist in the return month, the last day of the return month is returned. For example, September has 30 days; therefore, the two following statements return 2006-09-30 00:00:00.000:

    SELECT DATEADD(month, 1, '2006-08-30')

    SELECT DATEADD(month, 1, '2006-08-31')

    Learn something more today!

    Thanks

    very rightly pointed out...DATEADD does not check if the date is a valid date or not πŸ™‚

    Thanks for the question!

  • Been out for a while and just got to this. Nice question. Appreciate getting the brain back in gear with an easy one.

    Not all gray hairs are Dinosaurs!

  • Thanx for the question..

    i did not go for the catch 1+ 😎

    Neeraj Prasad Sharma
    Sql Server Tutorials

Viewing 10 posts - 16 through 24 (of 24 total)

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