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 |
|
Shabugeorge
Starting Member
5 Posts |
Posted - 2004-10-04 : 00:41:42
|
| Dear Friends,How do i get all the dates in a month.When i pass a month as a parameter then it should return all the dates in that month.Please Help.Thanks,Shabu |
|
|
VIG
Yak Posting Veteran
86 Posts |
Posted - 2004-10-04 : 02:40:43
|
| declare @month intset @month=4select dateadd(d,100*a+10*b+c,str(year(getdate()),4,0)+'0101')from(select 0 as a union all select 1 union all select 2 union all select 3 union all select 4 union allselect 5 union all select 6 union all select 7 union all select 8 union all select 9) as a,(select 0 as b union all select 1 union all select 2 union all select 3 union all select 4 union allselect 5 union all select 6 union all select 7 union all select 8 union all select 9) as b,(select 0 as c union all select 1 union all select 2 union all select 3 union all select 4 union allselect 5 union all select 6 union all select 7 union all select 8 union all select 9) as cwhere year(dateadd(d,100*a+10*b+c,str(year(getdate()),4,0)+'0101'))=year(getdate()) and month(dateadd(d,100*a+10*b+c,str(year(getdate()))+'0101'))=@month |
 |
|
|
slacker
Posting Yak Master
115 Posts |
Posted - 2004-10-04 : 02:44:01
|
Are you just trying to get the number of days in the month? declare @startDate datetime declare @subFrom datetime select @startDate = convert(datetime,'9/1/2004')select @subFrom = convert(datetime,'10/1/2004')select datediff(day,@startDate,@subFrom) |
 |
|
|
slacker
Posting Yak Master
115 Posts |
Posted - 2004-10-04 : 02:48:19
|
| Thats crazy VIG. It works too. |
 |
|
|
|
|
|
|
|