Solved

How to use the average function on HH:MM:SS fields in Report Builder 3.0

Posted on 2013-11-05
5
1,562 Views
Last Modified: 2014-01-06
I have a field in HH:MM:SS format and I would like to add an average at the bottom of my table report.  I receive an error when attempting to use AVG in a calculated field.  If I try to use the matrix report option, I loose my HH:MM:SS formatting and basic format options won't return it.  Any suggestions are greatly appreciated.

Thank you,
0
Comment
Question by:jaisy99
  • 2
5 Comments
 
LVL 2

Assisted Solution

by:burdit
burdit earned 500 total points
ID: 39625617
Two parts:
First on your sql side convert datetime into seconds
select datepart(hh,'00:48:38')*3600 + datepart(mi,'00:48:38') * 60 + datepart(ss,'00:48:38')

then in your report convert it back into datetime
CONVERT(datetime, DATEADD(ms, dateTimeInSeconds, 0))

this way you can average out the seconds and then convert it back into a date time
CONVERT(datetime, DATEADD(ms, AVG(dateTimeInSeconds), 0))
0
 
LVL 1

Author Comment

by:jaisy99
ID: 39625721
I have limited access to the report builder 3.0 only.
0
 
LVL 1

Accepted Solution

by:
jaisy99 earned 0 total points
ID: 39625915
Thank you for the suggestion.  Unfortunately, I don't have access to the SQL side of things, so I couldn't use it exactly, but here is a similar solution that worked in case others find it helpful.

First converted the initial field to seconds by adding a calculated field.
=DateDiff(DateInterval.Second,CDate(Fields!MyfieldName1.Value),CDate(Fields!MyfieldName2.Value))

Second, averaged and reformatted it with the following expression
=Format(DateAdd("s",Avg(Fields!MyFieldName3.Value), "00:00:00"), "HH:mm:ss")
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Introduction In the following article I’ll be discussing and demonstrating several different ways of how images can be put on a report. I’m using SQL Server Reporting Services 2008 R2 CTP, more precisely version 10.50.1352.12, but the methods ex…
Today, still in the boom of Apple, PC's and products, nearly 50% of the computer users use Windows as graphical operating systems. If you are among those users who love windows, but are grappling to keep the system's hard drive optimized, then you s…
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…
Both in life and business – not all partnerships are created equal. As the demand for cloud services increases, so do the number of self-proclaimed cloud partners. Asking the right questions up front in the partnership, will enable both parties …

895 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

18 Experts available now in Live!

Get 1:1 Help Now