declare @diff int,
@start_date datetime='2012-03-08 00:00:00.000',
@end_date datetime='2012-03-14 00:00:00.000'
declare @table table
(DateValue datetime)
set @diff =(select datediff(day,@start_date,@end_date))
--select @diff
declare @Flag int=0
WHILE (@Flag <= @diff)
BEGIN
insert into @table select DATEADD(day,@Flag,@start_date)
--PRINT @Flag
SET @Flag = @Flag + 1
END
select * from @table
Output
DateValue |
03/08/12 |
03/09/12 |
03/10/12 |
03/11/12 |
03/12/12 |
03/13/12 |
03/14/12 |
No comments:
Post a Comment