Click here to Skip to main content
13,004,421 members (78,964 online)
Click here to Skip to main content
Add your own
alternative version


1 view
Posted 28 Dec 2012

How to find Number of Days in Sql Server?

, 28 Dec 2012
try below code:-SELECT DATEPART(day, DATEADD(s,-1,DATEADD(mm,DATEDIFF(m,0,'2011-02-25')+1,0)))


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

28 Dec 2012
kirthiga 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
28 Dec 2012
try the below one and pass your requried monthSELECT DATEPART(dd, DATEADD(s,-1,DATEADD(mm,DATEDIFF(m,0,getdate())+1,0)))


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


About the Author

Software Developer
India India
No Biography provided

| | Privacy | Terms of Use | Mobile
Web01 | 2.8.170627.1 | Last Updated 29 Dec 2012
Article Copyright 2012 by ssd_coolguy
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid