Open Means Open Means

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())))

No comments

Login to post a comment

Show
  • Create an account
  • Forgot your username?
  • Forgot your password?
  • About Us
  • Faqs
  • Contact Us
  • Disclaimer
  • Terms & Conditions