[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Rahul

3/22/2007 6:35:00 AM

Hi,

how we can find out no of days in a particular month.
I am using sql server 2000

Rahul

3 Answers

Ramesh Subramaniyan

3/22/2007 7:13:00 AM

0


select datediff(day,'2/1/2006','3/1/2006') try this
previous month and next moth
"Rahul" wrote:

> Hi,
>
> how we can find out no of days in a particular month.
> I am using sql server 2000
>
> Rahul
>
>

Uri Dimant

3/22/2007 8:13:00 AM

0

Hi
1)
select dateadd(month,datediff(month,0,getdate())+1,0)-1
2)
declare @d datetime
set @d=getdate()
select datestring, case
when isdate(datestring/100*100+31) = 1 then 31
when isdate(datestring/100*100+30) = 1 then 30
when isdate(datestring/100*100+29) = 1 then 29
when isdate(datestring/100*100+28) = 1 then 28
end
from (
select convert(varchar,@d,112) as datestring
) D

3)
declare @d datetime
set @d = getdate()
select 32-day(@d-day(@d)+32)







"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
>


Mark Siltala

3/23/2007 4:44:00 PM

0

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
>