1

I am using RDLC Report. My requirement is, I need to calculate total Hours from values like

           Wrking Hour
             9:45 
             10:02

             11:00
Total Hours: 30:47

Main thing it is including blank values. So How I need to make equation for RDLC Report for getting total hours:minutes.

I tried running the below code, but it shows error:

System.TimeSpan.FromTicks(sum(Fields!TimeDiff.Value))
Yaron
  • 10,166
  • 9
  • 45
  • 65

2 Answers2

1

Your code works without an error but it would yield 1.06:47 which isn't your desired format. Unfortunately .NET doesn't have a format string for more than 24 hours (see also this answer).

You can get your desired result if you do the formatting yourself and show your result as a string:

=CStr(Math.Truncate(System.TimeSpan.FromTicks(Sum(Fields!TimeDiff.Value)).TotalHours)) +
 ":" + CStr(System.TimeSpan.FromTicks(Sum(Fields!TimeDiff.Value)).Minutes)
0

Try this..

=System.TimeSpan.FromMinutes(sum(Fields!TimeDiff.Value)).Hours