Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Dates in distinct ranges

Author  Topic 

RickD
Slow But Sure Yak Herding Master

3608 Posts

Posted - 2011-05-27 : 11:23:06
Any help appreciated as just can't get my head around this one:

I have a table:

DECLARE @Table TABLE ( ID INT , ListDate DATETIME , ToDate DATETIME )

INSERT INTO @Table
SELECT 1 , '2008-10-01' , '2016-01-01'
UNION SELECT 1 , '2008-10-01' , '2010-06-21'
UNION SELECT 1 , '2010-03-22' , '2016-01-01'
UNION SELECT 1 , '2010-08-30' , '2016-01-01'

Required result set:

ID , ListDate , ToDate
1 2008-10-01 2010-03-22
1 2010-03-22 2010-06-21
1 2010-06-21 2010-08-30
1 2010-08-30 2016-01-01

I just can not seem to get my head around how to do this in SQL 2000.

nigelrivett
Master Smack Fu Yak Hacker

3385 Posts

Posted - 2011-05-27 : 11:54:07
AN easy way would be to join to a days table with a between and take the distinct values

==========================================
Cursors are useful if you don't know sql.
SSIS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

RickD
Slow But Sure Yak Herding Master

3608 Posts

Posted - 2011-05-27 : 19:07:46
Not sure I can create one for this, but I may end up having to.

Cheers Nigel.
Go to Top of Page

RickD
Slow But Sure Yak Herding Master

3608 Posts

Posted - 2011-05-31 : 03:37:43
I guess no other takers on this one.
Go to Top of Page
   

- Advertisement -