Kishan Gajjar
Kishan Gajjar

Reputation: 1138

need help in sum of time in rdlc

I am working on attendance management system. In my project i want to display total worked hours of the employee in the daily report.

In my database table i have already calculated working hours for the each employee. Now i want to display Total worked hours of each and every entry at the bottom of the report.

e.g

EmployeeId EmployeeName  WorkedHours
1             ABC        04:00:25
2             XYZ        07:23:01
3             PQR        11:02:15

SO i want to display total of all 3 employees at the end of report in RDLC.

like Total: 22:25:42

Please let me know how can i achieve it?

Upvotes: 1

Views: 2752

Answers (4)

Shahid Ullah
Shahid Ullah

Reputation: 153

        Facing the same issue here is your final answer.

    Step1: Go to your textbox expression and past below code
 =Code.MinutesToHoursMinutes(SUM(Hour(Fields!TTShortTime.Value)*60)+SUM(Minute(Fields!TTShortTime.Value)))    

        Step2: Goto your rdlc report properties => Tab Code, Here past below function       
        Function MinutesToHoursMinutes(ByVal vMins As Integer) As String
        Dim Mins As Integer
        Dim Hours As Integer
        vMins = IIF(vMins <= 0, 0, vMins)
        Hours = Floor(vMins / 60)
        Mins = vMins - (Hours * 60)
        MinutesToHoursMinutes = IIF(Hours < 9, "0" & CStr(Hours), CStr(Hours)) & ":" & IIF(Mins < 9, "0" & 
        CStr(Mins), CStr(Mins))
        Return MinutesToHoursMinutes
        End Function


    Here in Step1 we get hours and convert it into minutes then get minutes and sum with hour calculated minutes.
    then passes it to function which returns string format like hh:mm

Upvotes: 0

Milton
Milton

Reputation: 1

Try This out and see if it works

=(SUM(Cint(Split(Fields!WORKEDHOUR.value,":").GetValue(0))) + (SUM(Cint(Split(Fields!WORKEDHOUR.Value,":").GetValue(1))) + Sum(Cint(split(Fields!WORKEDHOUR.Value,":").GetValue(2)))\60)\60 ).ToString + ":" + ((SUM(Cint(Split(Fields!WORKEDHOUR.Value,":").GetValue(1))) + Sum(Cint(split(Fields!WORKEDHOUR.Value,":").GetValue(2)))\60) Mod 60).ToString + ":" + (Sum(Cint(split(Fields!WORKEDHOUR.Value,":").GetValue(2))) Mod 60).ToString

Upvotes: 0

Caio Vitullo
Caio Vitullo

Reputation: 91

You can use the TimeStamp class gether with the Sum function, follow an example:

=TimeSpan.FromMinutes(Sum(Fields!Dirigindo.Value))

Upvotes: 0

pramodtech
pramodtech

Reputation: 6270

You just need to add =Sum(Fields!WorkedHours.Value) in footer row for "WorkedHours" column.

see the link in MSDN http://msdn.microsoft.com/en-us/library/ms252113(v=vs.80).aspx

Upvotes: 1

Related Questions