Date Difference

  • Comments posted to this topic are about the item Date Difference

  • easy one to start the day..

    ~ demonfox
    ___________________________________________________________________
    Wondering what I would do next , when I am done with this one :ermm:

  • Good question. Thanks!

    Here is a tip to understand:

    1) This is how "0" and "114" will look like when converted to DATETIME

    SELECT CAST(0 AS DATETIME) -- 1900-01-01 00:00:00.000

    SELECT CAST(114 AS DATETIME) -- 1900-04-25 00:00:00.000

    2) Now as per the question

    SELECT DATEADD(YY,114,0) --> adding 114 years to "1900-01-01 00:00:00.000" we get "2014-01-01 00:00:00.000"

    and

    SELECT DATEADD(YY,0,114) --> adding 0 years to "1900-04-25 00:00:00.000" we get "1900-04-25 00:00:00.000"

    3) Clearly, both are different. Hence answer is NO 🙂

    ~ 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

  • nice question....

    manik************

    Manik
    You cannot get to the top by sitting on your bottom.

  • Nice question.

    Thanks Lokesh for ur additional explaination...

    --
    Dineshbabu
    Desire to learn new things..

  • Dineshbabu (2/4/2013)


    Thanks Lokesh for ur additional explaination...

    Thanks Dinesh 🙂

    ~ 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

  • GOOD basic question 🙂

    ALso good explanation by Lokesh 🙂

    _______________________________________________________________
    To get quick answer follow this link:
    http://www.sqlservercentral.com/articles/Best+Practices/61537/

  • Good question, nice easy start to the week.

    Tom

  • This was removed by the editor as SPAM

  • Thanks for the basic one. +1

  • Nice 50/50 question that doesn't hurt the brain too much on the morning after Superbowl...:cool:

  • Nice question. Simple, but with a good point. Thank you Siddharth.

    [font="Verdana"]Please don't go. The drones need you. They look up to you.[/font]
    Connect to me on LinkedIn

  • kapil_kk (2/4/2013)


    GOOD basic question 🙂

    ALso good explanation by Lokesh 🙂

    +1 🙂

    _____________________________________________________________________
    [font="Comic Sans MS"]"The difficult tasks we do immediately, the impossible takes a little longer"[/font]

  • Really need to stop answering these before coffee. 😛

  • Easy one in a superbowl hangover..Thanx 🙂

    ___________________________________________________________________
    If I can answer a question then anyone can answer it..trying to reverse the logic.. :hehe:

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

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