1 | 100米 | 2011-05-01 00:00:00.000 |
2 | 马拉松 | 2011-05-04 00:00:00.000 |
3 | 铅球 |
2011-06-03 00:00:00.000
|
例如:起始时间2011-05-01,结束时间2011-07-01
结果:罗列出没有比赛项目的日期:
2011-05-02
2011-05-03
2011-05-05
.............
2011-06-01
2011-06-02
2011-06-04
..............
2011-06-28
2011-06-29
2011-06-30
2011-07-01
补充一下题目,看不懂。。。。。
这是我在SQL Server中写的:
create table #Temp(id int ,race varchar(50),dt datetime)
insert into #Temp select 1, '100米', '2011-05-01'
insert into #Temp select 2, '马拉松', '2011-05-04'
insert into #Temp select 3, '铅球', '2011-06-03'
create table #TempDate(dt datetime)
declare @startDate datetime
declare @endDate datetime
declare @tempDate datetime
set @startDate='2011-05-01'
set @endDate='2011-07-01'
set @tempDate=@startDate
while (@tempDate>=@startDate and @tempDate<=@endDate)
begin
insert into #TempDate select @tempDate set @tempDate=DATEADD(DAY, 1, @tempDate)
end
select dt from #TempDate where dt not in (select dt from #Temp)
drop table #Temp
drop table #TempDate