开发者

Records fetch for DataTable

I have added 1000 records into DataTable using C#.Net. This data table contains TimeStamp column for specified data stored ti开发者_如何学Gome. 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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜