Mark Siltala
3/23/2007 4:44:00 PM
OK, try this:
Create proc p_GetMonthDays (@year varchar(4),@month varchar(2))
as
declare @date char(10)
set @date = @month + '-01-' + @year
select datepart(day,dateadd(day,-1,(dateadd(month, 1, @date)))) 'Days In
Month'
You need to pass the year (2008) and month number (2),
exec p_GetMonthDays 2008,2
returns this:
Days In Month
-------------
29
(1 row(s) affected)
Of course, this could be 'neatened' up a lot (enter month name, convert to
month number, remove column name, No error checking, etc.), but it's a
start.
It starts with the first day of the month you enter, adds one month, goes
back one day, and gets that day number.
Mark Siltala
"Rahul" <verma.career@gmail.com> wrote in message
news:1174545274.095291.47870@p15g2000hsd.googlegroups.com...
> Hi,
>
> how we can find out no of days in a particular month.
> I am using sql server 2000
>
> Rahul
>