Calculation of total working hours

Total effort in hours

Can anyone plz assist me to get the sum of effort hours from excel column.
what would be the syntax, plz assist

Hi @vidhan.rpa
Did u need to add these values together

yes, please

Hi @vidhan.rpa,

Try this and let us know if it works.

dt.AsEnumerable().Sum(Function(row) row.Field(Of Decimal)(“Total effort in hours”))

Total effort in hours - this is your column name
dt- this is your datatable

1 Like

It is not working, error throwing as specified cast is not valid.

Yaa, Got that let me do some modification in that !


can u plz tell assist me on the below.

I have 60 different excel files in a 60 folder and those 60 folder is in another folder. How do I ready each file from them.

@vidhan.rpa - To read all the files with in subfolders , you can code like below.

FilesList = Directory.GetFiles(YourFolderpath," * .xlsx * ", SearchOption.AllDirectories)
Note:Remove the spaces after * and after xlsx * . i am not able to type with that format here…

Then loop through each files and build your process.

1 Like

It is working fine, can u tell me how do I get the filename and extension from the path. For example: In below path I want only filename as Format_SNR and extenstion .xlsx.
Plz tell me the syntax if u r aware.

“C:\Users\NI6991\Documents\UiPath#Project Documents#\Robert Bosch\Template Attachment Folder\I1234\Format_SNR.xlsx”

for only file name without extension use :


for only extension use:



@vidhan.rpa - As @Shikhar_Tandon mentioned , you can get the filename and the extension using those codes. You have do those inside your for each loop.

Hi ,
Using Slight modification in Linq Query i tried this .
Sum total of hours.xaml (9.2 KB)

Try this:

  1. In A1, enter Time In.
  2. In B1, enter Time Out.
  3. In C1, enter Hours Worked.
  4. Select A2 and B2, and press [Ctrl]1 to open the Format Cells dialog box.
  5. On the Number tab, select Time from the Category list box, choose 1:30 PM from the Type list box and click OK.
  6. Right-click C2, and select Format Cells.
  7. On the Number tab, select Time from the Category list box, choose 13:30 from the Type list box and click OK.
  8. In C2, enter the following formula: =IF(B2<A2,B2+1,B2)-A2
  9. If you enter 11:00 PM as the Time In and enter 7:00 AM as the Time Out, Excel will display 8, the correct number of hours worked.

Hope this helps you figure out your issue or you can get more help at O365CloudExperts.

Jerry M.