return the number of days per month

hi

please how can we return the number of days per month in a given year?

thanks.
RyanBankAsked:
Who is Participating?
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
the last day of the month is the same result, hence:

declare @date datetime
set @date = dateadd(day, 1- datepart(day, getdate()),getdate())
select datepart(day, dateadd(day, -1, dateadd(month, 1, @date))) as number_of_days_for_current_month
0
 
RyanBankAuthor Commented:
angelIII,

I can't seem to figure it out how to implement the last day of the month to a group by clause, can you assist?

http://www.experts-exchange.com/Databases/Microsoft_SQL_Server/Q_21897923.html
0
 
RyanBankAuthor Commented:
I found the answer, the data I was comparing with had a formula error that's why i though somethings wrong with averaging.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.