Please start any new threads on our new site at http://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

 SQL Server Forums Profile | Active Topics | Members | Search | Forum FAQ
 All Forums  SQL Server 2000 Forums  Transact-SQL (2000)  Show Dates by Date range Reply to Topic  Printer Friendly
Author  Topic

jonasalbert20
Constraint Violating Yak Guru

Philippines
300 Posts

 Posted - 06/21/2006 :  23:05:48 My reference on writing this code is from this linkhttp://www.sqlteam.com/forums/topic.asp?TOPIC_ID=45861&SearchTerms=aHere's the code:declare @DateFrom datetimedeclare @DateTo datetimeset @DateFrom = '2006/06/25'set @DateTo = '2007/12/05'select dateadd(d, adder.t, @DateFrom) as dayssssfrom ( select (i1 + i2 + i3 + i4 + i5 + i6 + i7 + i8) as t from (select 0 as i1 union select 1) as i1 left join (select 0 as i2 union select 2) as i2 on 1=1 left join (select 0 as i3 union select 4) as i3 on 1=1 left join (select 0 as i4 union select 8) as i4 on 1=1 left join (select 0 as i5 union select 16) as i5 on 1=1 left join (select 0 as i6 union select 32) as i6 on 1=1 left join (select 0 as i7 union select 64) as i7 on 1=1 left join (select 0 as i8 union select 128) as i8 on 1=1 where (i1 + i2 + i3 + i4 + i5 + i6 + i7 + i8) <= datediff(d, @DateFrom, @DateTo) ) as adderorder by dateadd(d, adder.t, @DateFrom)I want to show the date by date range. Any another approach?tnx in advance.Want Philippines to become 1st World COuntry? Go for World War 3...

khtan
In (Som, Ni, Yak)

Singapore
17689 Posts

 Posted - 06/21/2006 :  23:10:14 `select * from dbo.F_TABLE_DATE ( '2006-06-25' , '2007-12-05' )`Get the F_TABLE_DATE from hereKH

jonasalbert20
Constraint Violating Yak Guru

Philippines
300 Posts

 Posted - 06/22/2006 :  00:01:25 another one?I am currently rewritting the F_TABLE_DATE in MySQL. I want a flexible approach so that i will not be having a hard time for my needs.Tnx khtan.Want Philippines to become 1st World COuntry? Go for World War 3...

 Posted - 06/22/2006 :  04:55:01 Try this``` Declare @date table(d datetime) Declare @DateFrom datetime, @DateTo datetime set @DateFrom = '2006/06/25' set @DateTo = '2007/12/05' While @DateFrom<=@DateTo Begin Insert into @date values (@DateFrom) set @DateFrom=@DateFrom+1 End Select d from @date```MadhivananFailing to plan is Planning to fail