Problem with Subtraction of Dates

  • I have to get the difference of dates of single column, the table is temporary table. The records will be inserted into the table through a cursor ( it will retriev values from another table and insert into this temporary table ) and also i have a column called "StopsTheClock". If the value changes from 0 to 1 or remains same i have to subtract dates and store the value.

    For eg:

    _ID_______Date________________StopsTheClock

    _1_______03/03/2007______________0_________

    _2_______03/04/2007______________0_________

    _3_______03/06/2007______________1_________

    _4_______03/09/2007______________0_________

    _5_______03/20/2007______________1_________

    _6_______03/27/2007______________0_________

    My calculation should be

    (date1-date2)+(date2-date3)+(date4-date5)+(date6-getdate())

    plz mail me if u got solution naveenwinsome@gmail.com

     

    Naveen

  • What should the result of this calculation be based on your example?

     

  • Lynn question is very relevant but you should be using the DATEDIFF function to do the math. See Books on line for the details.

  • Asked and answered here

    http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=81761

     


    N 56°04'39.16"
    E 12°55'05.25"

Viewing 4 posts - 1 through 3 (of 3 total)

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