SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Show Dates by Date range
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

jonasalbert20
Constraint Violating Yak Guru

Philippines
300 Posts

Posted - 06/21/2006 :  23:05:48  Show Profile  Send jonasalbert20 a Yahoo! Message  Reply with Quote
My reference on writing this code is from this link
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=45861&SearchTerms=a

Here's the code:

declare @DateFrom datetime
declare @DateTo datetime

set @DateFrom = '2006/06/25'
set @DateTo = '2007/12/05'

select dateadd(d, adder.t, @DateFrom) as dayssss
from (
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 adder
order 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
17681 Posts

Posted - 06/21/2006 :  23:10:14  Show Profile  Reply with Quote
select * from dbo.F_TABLE_DATE ( '2006-06-25' , '2007-12-05' )


Get the F_TABLE_DATE from here


KH

Go to Top of Page

jonasalbert20
Constraint Violating Yak Guru

Philippines
300 Posts

Posted - 06/22/2006 :  00:01:25  Show Profile  Send jonasalbert20 a Yahoo! Message  Reply with Quote
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...
Go to Top of Page

madhivanan
Premature Yak Congratulator

India
22772 Posts

Posted - 06/22/2006 :  04:55:01  Show Profile  Send madhivanan a Yahoo! Message  Reply with Quote
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


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000