Solved

return the number of days per month

Posted on 2006-06-24
3
237 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
  • 2
3 Comments
 
LVL 142

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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

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

Having an SQL database can be a big investment for a small company. Hardware, setup and of course, the price of software all add up to a big bill that some companies may not be able to absorb.  Luckily, there is a free version SQL Express, but does …
Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.

910 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now