Here I provide T-SQL Statement to get no of days in month using SQl server 2005

DECLARE @Date datetime,@DaysInMonth int
set @date='02/01/2009'
SET @DaysInMonth=Day(DateAdd (Month,1,@date)-Day(DateAdd(Month,1,@date)))
select @DaysInMonth

This out put will be 28.

This is the easy way to find the noof days in a month

This example using parameter we give prticular date

If u want to get a current month days using Getdate function instead of @date parameter

Here

select Day(DateAdd (Month,1,getdate())-Day(DateAdd(Month,1,getdate())))


Like it on Facebook, Tweet it or share this article on other bookmarking websites.

No comments