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

Posted on 2011-10-27
Last Modified: 2013-12-16
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.
Question by:thenthorn1010
    1 Comment
    LVL 1

    Accepted Solution

    datatable.Select("DateReceived = MIN(DateReceived)")
    datatable.Select("DateReceived = MAX(DateReceived)")

    Featured Post

    Courses: Start Training Online With Pros, Today

    Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

    Join & Write a Comment

    Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
    How to install Selenium IDE and loops for quick automated testing. Get Selenium IDE from ( Go to that link and select download selenium in the right hand columnThat will then direct you to their downlo…
    This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
    THe viewer will learn how to use NetBeans IDE 8.0 for Windows to perform CRUD operations on a MySql database.

    733 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    21 Experts available now in Live!

    Get 1:1 Help Now