I know this question was for SQL Server 2005, but I thought I'd mention- as of SQL 2012, there now is an EOMONTH() function that gets the last day of the month. To get it in the format specified by the original asker you'd have to cast to a datetime.
I know this question was for SQL Server 2005, but I thought I'd mention- as of SQL 2012, there now is an
EOMONTH()
function that gets the last day of the month. To get it in the format specified by the original asker you'd have to cast to adatetime
.Select DATEADD(DAY, -(DAY(DATEADD(MONTH, 1, GETDATE()))),DATEADD(MONTH, 1, GETDATE()))
This works great in T-sql ..
Replace the GETDATE() of the query with your column name .
http://php.net/manual/en/function.cal-days-in-month.php
The length in days of the selected month in the given calendar