• suresh0534 (2/5/2014)


    Thanks for your reply,

    But there is no end date....I need to calculate the End date based on Start Date.

    Example I am calculating the 2013 year Data.

    If Start date date 2014 year , but we need to calculate only 2013 date..so there is no end date for 2014 Year.

    I taken Start Date is Order By Desc.....for Highest Date it needs to calculate the Year End Date (12/31/2013).

    Below is The Sample Out Put Based On Start Date..need to Calculate The End Date

    id cid start_date end_date

    1 100 02/23/2014 --

    1 100 06/25/2013 12/31/2013

    1 100 06/04/2013 06/24/2013

    1 100 06/17/2013 06/03/2013

    2 200 08/9/2013 12/31/2013

    2 200 08/03/2013 08/08/2013

    Your end dates make no common sense.

    You have multiple End dates that are end of year. Based on your statement that the highest start date should be the end of the year for the end date, we have a conflict there.

    Then you have the bolded start and end date where the end date is prior to your start date.

    Then you have some end dates that are 20 days from start date and some that are just 5 days from the start date.

    Are you trying to say that an end date just goes to the next start date in sequence? Well if so, then we still have a conflict in your sample data in that that sequence is still not consistent.

    We still need to have a more precise and clear set of rules to follow. We need to have a better set of data.

    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