Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 987981
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T05:34:15+00:00 2026-05-16T05:34:15+00:00

i have an datatable like this. i am getting this data from an excel

  • 0

i have an datatable like this.
i am getting this data from an excel sheet and converted to datatable

id  workedhours  tfshours
1     3          2
2     5          5
3     .7         3
4      2         3.2
5     4.3       6.8 

now i need the sum of the column workedhours and tfshours

how can i achive that is .there any builtin function to get the sum of teh column

i need the result like this in a new datatable

 workedhours   tfshours
15                20

any help would be greatly appreicated.
thank you

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T05:34:16+00:00Added an answer on May 16, 2026 at 5:34 am

    Create a new Datatable and use the datatable.compute methods.

            DataTable sumDataTable = new DataTable();
            sumDataTable.Columns.Add("total", typeof(string));
            sumDataTable.Columns.Add("workedhours", typeof(int));
            sumDataTable.Columns.Add("tfshours", typeof(int));
    
            DataRow row = sumDataTable.NewRow();
            row["total"] = "Total";
            row["workedhours"] = oldDataTable.Compute("Sum(workedhours)", "workedhours > 0");
            row["tfshours"] = oldDataTable.Compute("Sum(tfshours)", "tfshours > 0");
            sumDataTable.Rows.Add(row);
    

    The second parameter, filter, determines which rows are used in the expression, but you could just put “” to select all rows.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am working on reading data from excel sheet. My table will look like
I have a Datatable function like this public DataTable LoadCategory(SetupCategoryBO scBO) { DBConnect myConnection
I have a on memory Datatable like this. I want to produce xml file
I have a untyped DataTable that looks like this (srcTbl): date col_1 col_2 ...
I have a data.table object like this one library(data.table) a <- structure(list(PERMNO = c(10006L,
I'm a bit confused on this. I have a data table structured like this:
Say I have a DataGridView Control, this grid is filled through a DataTable. Now,
i am importing data from excel to sqlserver..i have filled the dataset with the
I have a SQL connection string like this: Data Source=myServerAddress;Initial Catalog=myDataBase;User Id=myUsername;Password=myPassword; I have
I have a datatable like public DataTable functiongettable() { DataTable dt = new DataTable();

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.