We help IT Professionals succeed at work.
Get Started

SQL to count the amount of hours between two dates, split by Quarter

Last Modified: 2015-02-27
I'm struggling to create a chart in SSRS (output from SQL Query) that will show how many project hours have been spent during a quarter. If the total number of hours crosses several quarters, each quarter should have the total number of hours spent during each quarter)

I understand that using DATEDIFF(hh, ProjectStartDate, ProjectFinishDate)as [Total Number of Hours] will give me the total number of hours of a project but I need to be able to split the output into Quarters

i.e. Q1 2014, Q2 2014, Q3 2014, Q4 2014, Q1 2015 etc.

Please see attached image to show what I am aiming for with the results.projectworkdistribution.JPG
Fields in SQL table: Project Name, ProjectStartDate, ProjectEndDate

Exepected output:
Quarter              TotalHoursSpent
Q1 2014              1,800 Hours
Q2 2014              1,992 Hours
Q3 2014              990 Hours
Q4 2014              800 Hours
Q1 2015              950 Hours

Many thanks in advance!
Watch Question
Director, Practice Manager and Computing Consultant
Awarded 2014
Top Expert 2014
This problem has been solved!
Unlock 1 Answer and 6 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE