Alright, let\'s say I have a table that looks like this:
ID | DATE
2 | 2010-08-12
2 | 2010-08-16
2 | 2010-08-17
2 | 2010-12-21
2 | 2010-12-22
These two links will give you a rough idea.
if you have serialize id like ( 1,2,3,4,5,..) then you can get the above with this query with 1 extra data at last but you can omit that
the folloowing is the mysql query
SELECT startdate, ( select startdate - INTERVAL 1 DAY from tester
a where a.id = b.id +1) as enddate FROM tester
b
I will not put here the ID as I see it is irrelevant in the query. If you wish you will put it later. This is a MSSQL query.
select tb1.date as startdate,dateadd(d,-1,tb2.date) as enddate
from the_table tb1
join the_table tb2 on tb2.date>tb1.date
left join the_table tb3 on tb1.date<tb3.date and tb3.date<tb2.date
where tb3.date is null
It can be easily translated for other DB types.