In my RDLC report i am displaying times worked by employees.
I want to sum the time for each employee. I am returning the hours worked in a record set using a nullable timeSpan type and formatting them as hh:mm in the report as so:
7:30
4:45
5:30
7:30
7:30
There have been numerous other questions asked around the same issue such as this , and this, but none seem to have an acceptable answer.
This question is almost what i want. Except it shows day , hour , minute , second.
But my users want the total hours and minutes only, no days i.e. in this scenario i want to see 32 hours 45 minutes.
7:30
4:45
5:30
7:30
7:30
---------
Total: 32:45
I have tried the following formula, but i get a #error:
=TimeSpan.FromMinutes(Sum(Fields!Hours.Value))
And :
=Sum(Fields!Hours.Value)
And this one gives me the days,hours,mins...so is close , but i need just total hh:mm:
=TimeSpan.FromTicks(Sum(Fields!Hours.Value))
Is this possible ?
I would try the parts as you can get them.
=(TimeSpan.FromTicks(Sum(Fields!Hours.Value)).Days * 24 + TimeSpan.FromTicks(Sum(Fields!Hours.Value)).Hours).ToString +":" + TimeSpan.FromTicks(Sum(Fields!Hours.Value)).Minutes.ToString("d2")
The minutes in this case would have your :45, but the string formatting would have to allow for a single digit in hours as showing 2 digits, thus a possible leading zero if less than 10 minutes.