Solved

return the number of days per month

Posted on 2006-06-24
3
263 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
What if you have to shut down the entire Citrix infrastructure for hardware maintenance, software upgrades or "the unknown"? I developed this plan for "the unknown" and hope that it helps you as well. This article explains how to properly shut down …
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

632 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