Solved

return the number of days per month

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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
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.
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

744 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

10 Experts available now in Live!

Get 1:1 Help Now