Solved

return the number of days per month

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

Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

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

Suggested Solutions

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 …
Introduction In my previous article (http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SSIS/A_9150-Loading-XML-Using-SSIS.html) I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
Via a live example, show how to shrink a transaction log file down to a reasonable size.
Via a live example, show how to setup several different housekeeping processes for a SQL Server.

773 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