Solved

return the number of days per month

Posted on 2006-06-24
3
260 Views
Last Modified: 2006-11-18
hi

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

thanks.
0
Comment
Question by:RyanBank
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 500 total points
ID: 16975297
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
 

Author Comment

by:RyanBank
ID: 16975399
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
 

Author Comment

by:RyanBank
ID: 16975457
I found the answer, the data I was comparing with had a formula error that's why i though somethings wrong with averaging.
0

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
Via a live example, show how to setup several different housekeeping processes for a SQL Server.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

710 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question