• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 747
  • Last Modified:

How to Retrieve the Minimum Date and Maximum Dates in a C# DataTable using the DataTable.Select() Command

I am attempting to write and expression to use the DataTable.Select() method in order to retreive the maximum and minimum dates that are found within a C# datatable. For instance, if I had the DataTable called results and it had the columns "DateReceived", "Size", "Color", and "Price", how would I find the maximum "DateReceived" if it is a "DateTime" type and how would I find the minimum "DateReceived" value? Could someone help me with the syntax for this task? I have checked the MSDN webpages, and I have found very little on the syntax that would be required to do this.

Any help that you would be able to provide would be greatly appreciated.
0
thenthorn1010
Asked:
thenthorn1010
1 Solution
 
ItpotterCommented:
datatable.Select("DateReceived = MIN(DateReceived)")
or
datatable.Select("DateReceived = MAX(DateReceived)")
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now