Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
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.
Mona writes "Hi,i have a table of employees with a from-date, to-date range. i want to be able to return all the days that are included in the range, using a query. Thank you for any help"
RickD
Slow But Sure Yak Herding Master
3608 Posts
Posted - 2004-06-07 : 08:12:16
declare @StDate datetime
declare @EndDate datetimeselect @StDate = [from-date], @EndDate = [to-date] from employees where empid = 1while @StDate <= @EndDate begin insert into @tblDates select @StDate set @StDate = dateadd(d,1,@StDate) endselect adate from @tblDates