dt.Columns.Add("CaseNumber");
dt.Columns.Add("Subject");
dt.Columns.Add("Description");
dt.Columns.Add("Owner");
dt.Columns.Add("CreatedDate");
for (int i = 0; i < qr.records.Length; i++)
{
Case newCase = (Case)qr.records[i];
DataRow dr = dt.NewRow();
dr["CaseNumber"] = newCase.CaseNumber;
dr["Subject"] = newCase.Subject;
dr["Description"] = newCase.Description;
dr["Owner"] = newCase.Owner.Name1;
dr["CreatedDate"] = newCase.CreatedDate;
dt.Rows.Add(dr);
So, what I need is to find all records by a particular product in the "Owner" column and then select the oldest case by the "CreatedDate" column.Select multiple items from DataTable based on multiple criteria...
Hello,
I have a bit of an interesting scenario that I need assistance with. I have a DataTable that has five columns. The last column is the date that the record was created. The first column is for the product name. I need to be able to pull the oldest date per product. Is this possible without Linq? I know that I can sort the DataTable and get the oldest overall. And, I could also just set up DataTables per product and pull the information from there. Is there a way to accomplish this with one DataTable? Snippet below:
Sam HobbsPosted Nov 2, 2009, 3:59 PM
Sam HobbsPosted Nov 2, 2009, 3:56 PM
JosephPosted Nov 2, 2009, 3:01 PM
JosephPosted Nov 2, 2009, 11:57 AM
The query that you built for me in LINQ works beautifully sans one problem. It is pulling the oldest date up to the time but it does not take in to account AM/PM. So, the earliest records is in this format "10/29/2009 10:00:45 PM", however, the earliest records should be "10/29/2009 10:00:53 AM". Know of any solution? It would be much easier if it were in 24-hour format instead of 12, but, unfortunatley, it isn't :). And, I had to change "query.Max(p => p.CreatedDate))" to "query.Min..." in order for it to pull the older times. I really appreciate all of your help thus far.
JosephPosted Nov 2, 2009, 9:53 AM
" at the end of the line for it to start a new line. Again, I will update you in just a while to let you know how things pan out. Thanks so much for the suggestions btw.
Sam HobbsPosted Nov 1, 2009, 12:17 AM
Sam HobbsPosted Nov 1, 2009, 12:14 AM
jingePosted Oct 31, 2009, 5:54 AM
Sam HobbsPosted Oct 31, 2009, 2:32 AM
naura paxPosted Oct 31, 2009, 1:44 AM
you can sort and filter using datatable's select method which returns a datarow array:
DataRow[] drArr=dt.Select("OrderNo='" + txtOrderNo.Text + "'","[CreateDate] Desc");
// There is a single quote after OrderNo= and in third string in first argument, //second argument is optional.
DataTable dtNew=new DataTable();
for(int i=0;i