Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8983919
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T20:57:42+00:00 2026-06-15T20:57:42+00:00

That question probably sounded extremely confusing, but it’s difficult to describe what I want

  • 0

That question probably sounded extremely confusing, but it’s difficult to describe what I want to do. Basically, I have a list of DateTime objects and I want to make a new list that contains the objects from the list that represent the latest time for each date represented in the list. For example, say I have a list containing these DateTimes:

  • 12/13/2012 2:00:00 AM
  • 12/13/2012 4:00:00 AM
  • 12/13/2012 8:00:00 PM
  • 12/14/2012 5:00:00 PM
  • 12/14/2012 3:00:00 AM
  • 12/15/2012 10:00:00 AM

I want my results list to contain the following:

  • 12/13/2012 8:00:00 PM
  • 12/14/2012 5:00:00 PM
  • 12/15/2012 10:00:00 AM

I know I can do this using LINQ. I’m just having a hard time trying to wrap my mind around what is happening. I think I have to select from an IEnumerable<IEnumerable<DateTime>> where the inner IEnumerable is a list of DateTimes that all have the same date, and then I want to order those by descending and select the first one.

I am quite lost…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T20:57:43+00:00Added an answer on June 15, 2026 at 8:57 pm

    Try this:

    var dates = list.GroupBy(dt => dt.Date).Select(g => g.Max());
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a question that is probably very simple, but I cannot find an
I have a general question that was probably answered somewhere here, but using search
This is probably a basic html/css question... I have a simple one-button form that
This is probably a pretty basic question, but just something that I wanted to
This is probably a multi-part question. Background: we have a native (c++) library that
I realise that this question has probably been asked to death, but none of
I half realize that this question is probably asked already, but I'm not familiar
I've got a question that probably has a pretty simple answer, but I didn't
This is probably a question that is more about object alloc/retain/release, but I'll use
This is probably a question that has an easy/simple/obvious answer, but I've found myself

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.