日期:2014-05-17 浏览次数:20465 次
create function generateTime
(
@begin_date datetime,
@end_date datetime
)
returns @t table(date datetime)
as
begin
with maco as
(
select @begin_date AS date
union all
select date+1 from maco
where date+1 <=@end_date
)
insert into @t
select * from maco option(maxrecursion 0);
return
end
select distinct DATEPART(mm,[date]) from dbo.generateTime('2013-5-20','2013-7-20')
/*
-----------
5
6
7
*/