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.
| Author |
Topic |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2005-08-30 : 08:00:17
|
| Ryan writes "Hi, Just wonder if i can get a period of dates to be inserted into a temp table (with a single field [Sales_Date]) base on a Start and End Date using a select query?For Eg,Start = '8/1/2005', End = '8/5/2005'In the temp table,8/1/20058/2/20058/3/20058/4/20058/5/2005 Your help is appreciated. Thks.RgdsRyan" |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2005-08-30 : 08:11:02
|
| Create table #date(d datetime)Declare @startDate Datetime, @EndDate DatetimeSet @startDate ='2005-08-01'Set @EndDate ='2005-08-05'While DateDiff(d,@startDate,@EndDate)>=0BeginInsert into #date values (@startDate)set @startDate=DateAdd(d,1,@startDate)EndSelect d from #dateMadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|