tags:

views:

35

answers:

1

Hi,

I have added 1000 records into DataTable using C#.Net. This data table contains TimeStamp column for specified data stored time. Data stored into 10.00AM to 11.00AM every 10 seconds once. Here i want to fetch only 10.15AM to 10.30AM records using C#.

Thanks

A: 

If you are using VS2008/.NET 3.5, just add a reference to System.Data.DataSetExtensions to your project, and do this:

var filteredList = myDataTable.AsEnumerable().Where(dataRow =>
                {
                    DateTime rowTimeStamp = 
                       Convert.ToDateTime(dataRow["TimeStamp"]);
                    return (rowTimeStamp.Hour == 10 && 
                           (rowTimeStamp.Minute >= 15 && 
                              rowTimeStamp.Minute <= 30));
                }).ToList();

This will give you a List object which you can work with.

code4life