Click here to Skip to main content
15,888,527 members
Articles / Database Development / SQL Server / SQL Server 2008

How to find Number of Days in Sql Server?

Rate me:
Please Sign up or sign in to vote.
0.00/5 (No votes)
28 Dec 2012CPOL 0  
try below code:-SELECT DATEPART(day, DATEADD(s,-1,DATEADD(mm,DATEDIFF(m,0,'2011-02-25')+1,0)))

Alternatives

Members may post updates or alternatives to this current article in order to show different approaches or add new features.

Please Sign up or sign in to vote.
28 Dec 2012kirthiga S 2 alternatives  
How to find Number of Days in Sql Server for a specific dateFor Example Declare @date datetime='2012-11-25'I have to find No. of days for @date (ie)Number of days for November monthMy answer should be 30
Please Sign up or sign in to vote.
28 Dec 2012FranklinRemo
try the below one and pass your requried monthSELECT DATEPART(dd, DATEADD(s,-1,DATEADD(mm,DATEDIFF(m,0,getdate())+1,0)))

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer
India India
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions