Need to Split a Date Column into 2 solumn as Start Date and End Date

  • I need help over this thing. I am working on a table which looks like

    Date Dateofyear

    2014-01-01 1

    2014-01-02 2

    2014-01-03 3

    2014-01-04 4

    2014-01-05 5

    . .

    ..

    ..

    2014-12-31 365

    Now i need to Run a query on this table to show me result after taking input from user (store proc ) if user enters 2 then

    StartDate EndDate

    2014/01/01 2014/07/01

    2014-07-02 2014-12-31

    and if user enter 5 then

    StartDate EndDate

    2014/01/01 2014-03-14

    2014-03-15 2014-05-26

    2014-05-27 2014-08-07

    2014-08-08 2014-10-19

    2014-10-19 2014-12-31

    I hope I made it clear; kindly Help me over this.

    Alot of thanks in Advance ;

    please

  • Please do not crosspost. It wastes peoples time and fragments replies.

    Original thread with replies can be found here:

    http://www.sqlservercentral.com/Forums/Topic1548128-8-1.aspx

    Need an answer? No, you need a question
    My blog at https://sqlkover.com.
    MCSE Business Intelligence - Microsoft Data Platform MVP

  • hy there, I got looped on submit button.

    and could not find any option to delete my post.

    Sorry if this bothered you

  • AdityaSingh (3/6/2014)


    hy there, I got looped on submit button.

    and could not find any option to delete my post.

    Sorry if this bothered you

    It didn't bother me.

    It could bother me if I would have taken some of my time to write you a query only to find out someone already did that on your other thread a few days ago. Luckily I was first 😀

    Need an answer? No, you need a question
    My blog at https://sqlkover.com.
    MCSE Business Intelligence - Microsoft Data Platform MVP

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

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