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.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 adding dates

Author  Topic 

dirwin26
Yak Posting Veteran

81 Posts

Posted - 2005-09-20 : 10:38:30
I need to insert dates to cover the range from tomorrow to 365 days from tomorrow. ideally with no business days. I've been messing around with the below, which of course adds only tomorrow's date....but I am having problems taking it further. Can anyone answer this?

INSERT INTO #res (TheDate)
VALUES (GETDATE() + 1)

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-09-20 : 10:44:05
See if this helps you



Declare @t table(d datetime)
Declare @i int
set @i=1
while @i<=365

Begin
insert into @t values(Getdate()+@i)
set @i=@i+1
end

select * from @t


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

dirwin26
Yak Posting Veteran

81 Posts

Posted - 2005-09-20 : 10:54:55
It worked like a charm!

Thanks
Go to Top of Page
   

- Advertisement -