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
 SQL Server Development (2000)
 GENERATING DATES

Author  Topic 

Freddie
Starting Member

29 Posts

Posted - 2006-03-29 : 13:32:29
Hello:

Can you help me generate dates into a table going back 3 years based on getdate().


Muchas Gracias.

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2006-03-29 : 13:45:55
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=61519

Go with the flow & have fun! Else fight the flow
Blog thingie: [URL="weblogs.sqlteam.com/mladenp"]
Go to Top of Page

Srinika
Master Smack Fu Yak Hacker

1378 Posts

Posted - 2006-03-29 : 15:30:15
Check whether the following helps u

Declare @t table(d Datetime)
Declare @i int, @ld int

Set @i = 0
Set @ld = 3 * 365

while @i < @ld
Begin
Insert into @t values(getdate()- @i)
Set @i = @i + 1
End
Select * from @t order by d asc


Srinika
Go to Top of Page
   

- Advertisement -