need help in sum of time in rdlc

瘦欲@ 提交于 2019-12-24 09:26:53

问题


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?


回答1:


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




回答2:


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

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




回答3:


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



回答4:


        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


来源:https://stackoverflow.com/questions/8264878/need-help-in-sum-of-time-in-rdlc

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!