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

  • SEARCH
  • Home
  • 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 4568128
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T19:01:55+00:00 2026-05-21T19:01:55+00:00

I am trying to return only the year end information (December 31) for the

  • 0

I am trying to return only the year end information (December 31) for the past five years and display that information in a DataGrid. This does not include the current year.

My program is currently displaying month’s end information from the previous year up to the last day of the most recent month in the current year (Example: The current month is May 2011 and the information being displayed in my DataGrid shows the data stored on Jan. 31, 2010; Feb. 28, 2010; Mar. 31, 2010….Dec. 31, 2010; Jan. 31, 2011; Feb. 28, 2011; Mar. 31, 2011; Apr. 30, 2011).

It also adds a totals row after Dec. 31, 2010 and another after Apr. 30, 2011. These two totals rows will not be needed in the new DataGrid.

Below is a snippet of the current code which is returning the months end information.

Please let me know if I left any information out or am not clear on my question.

I apologize in advance for such a rookie question, it has just been driving me crazy the past couple days that I cannot figure this out.

protected DataSet DS;
protected DataRow dr, dNew;

private void GetInfo()
{

}

private double getDbl(string columnName)
{
    if (dr[columnName] != DBNull.Value)
        return Double.Parse(dr[columnName].ToString());
    return 0;
}

private void Calculate()
{
    double cg, na, n, ka, nka, kaa, tca;
    double tmr, to, gpo;
    int year, rowcnt, rowindx, months;

    months = -1;
    rowindx = 0;
    cg = 0;
    na = 0;
    n = 0;
    ka = 0;
    nka = 0;
    kaa = 0;
    tca = 0;
    tmr = 0;
    tor = 0;
    gpo = 0;

    rowcnt = DS.Tables[0].Rows.Count;

    if (rowcnt > 0) year = Int32.Parse(DS.Tables[0].Rows[0]["cy"].ToString());
    else year = 0;

    for (int i = 0; i < rowcnt; i++)
    {
        months++;
        dr = DS.Tables[0].Rows[i]

        if (year != Int32.Parse(dr["cy"].ToString())
        {
            dNew = DS.Tables[0].NewRow();
            dNew["ind"] = rowindx;
            dNew["cg"] = cg;
            dNew["na"] = na;
            dNew["n"] = n;
            dNew["ka"] = ka / months;
            dNew["nka"] = nka / months;
            dNew["kaa"] = kaa / months;
            dNew["tca"] = tca / months;
            dNew["tmr"] = tmr / months;
            dNew["tor"] = tor;
            dNew["gpo"] = gpo / months;

            cg = 0;
            na = 0;
            n = 0;
            ka = 0;
            nka = 0;
            kaa = 0;
            tca = 0;
            tmr = 0;
            tor = 0;
            gpo = 0;
            months = 1;
            year = Int32.Parse(dr["cy"].ToString());
            rowindx++;

            DS.Tables[0].Rows.Add(dNew);

            dNew = DS.Tables[0].NewRow();
            dNew["ind"] = rowindx;
            rowindx++;
            DS.Tables[0].Rows.Add(dNew);
        }

        cg += getDbl("cg");
        na += getDbl("na");
        n += getDbl("n");
        ka += getDbl("ka");
        nka += getDbl("nka");
        kaa += getDbl("kaa");
        tca += getDbl("tca");
        tmr += getDbl("tmr");
        tor += getDbl("tor");
        gpo += getDbl("gpo");
        dr["ind"] = rowindx;
        rowindx++;
    }

    dNew = DS.Tables[0].NewRow();
    dNew["ind"] = rowindx;
    dNew["cg"] = cg;
    dNew["na"] = na;
         dNew["n"] = naum;
         dNew["ka"] = ka / months;
         dNew["nka"] = nka / months;
         dNew["kaa"] = kaa / months;
         dNew["tca"] = tca / months;
         dNew["tmr"] = tmr / months;
         dNew["tor"] = tor;
         dNew["gpo"] = gpo / months;
         DS.Tables[0].Rows.Add(dNew);

      DS.Tables[0].DefaultView.Sort = "ind";
}
  • 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-21T19:01:57+00:00Added an answer on May 21, 2026 at 7:01 pm

    Have you tried limiting the dataset query to just the year the you want?

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

Sidebar

Related Questions

I am trying to write a linq query that will only return certain columns
I'm trying to use a Year-Week format in oracle SQL to return results only
So I am trying to return only the records that are set to default
I am trying to write a query that will return only the most recent
Hi I am trying to return only a certain element from xml.. it is
i'm trying to return a custome object from a web service object returned only
Im trying to return the value that a $ajax call returns, from a function
Im trying to return a SimpleQuery list that queries a single table and uses
i'm trying to write a Sudoku solver which will return only the first possible
Below is my syntax. Im trying to only return the rows where assg.Hours_Act <>

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.