Solved

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

Posted on 2013-11-05
5
1,598 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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

This code started out as a fix for a customer that had incoming data that was hunderds of numbers and words long that was to fit in one column. The problem was that the customer did not want to split words or numbers when wrapping in the column. …
Hi, I have heard from my friends that it’s not possible to create Label Printing report using SSRS. I am amazed after hearing this words not possible in SSRS. I googled lot and found that it is possible to some of people know about the Report Bui…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

770 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