Here is my situation:
CREATE TABLE Test
(Rowid int,
Dt Datetime)
INSERT INTO Test VALUES(1, '01/01/2004')
INSERT INTO Test VALUES(2, '01/15/2004')
INSERT INTO Test VALUES(3, '01/31/2004')
and I want data like:
Rowid start_dt end_dt
1 01/01/2004 01/14/2004
2 01/15/2004 01/30/2004
3 01/31/2004 Today's Date
So in a nut shell I want next rows date minus 1 day on the previous row and if there is no next row then get today's date.
Please note that the RowId column is not sequential and neither the date is equally apart.
Thanks for all your help
CREATE TABLE Test
(Rowid int,
Dt Datetime)
INSERT INTO Test VALUES(1, '01/01/2004')
INSERT INTO Test VALUES(2, '01/15/2004')
INSERT INTO Test VALUES(3, '01/31/2004')
and I want data like:
Rowid start_dt end_dt
1 01/01/2004 01/14/2004
2 01/15/2004 01/30/2004
3 01/31/2004 Today's Date
So in a nut shell I want next rows date minus 1 day on the previous row and if there is no next row then get today's date.
Please note that the RowId column is not sequential and neither the date is equally apart.
Thanks for all your help