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

  • Home
  • SEARCH
  • 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 1105971
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T01:43:08+00:00 2026-05-17T01:43:08+00:00

Apologies for using someone else’s brain for this, but I’m sure this is a

  • 0

Apologies for using someone else’s brain for this, but I’m sure this is a common problem and has some sort of design pattern solution that I’ve not come across before.

I have an IList of objects that each have a “start” and a “stop” date. These date ranges can overlap. What I need to do is select which object is current for today’s date. If there’s an overlapping date then I need to select the one that has a start date closest to today’s date which which the stop date hasn’t passed.

I haven’t used Linq much but I get the impression it might be ideal for this kind of task.

Can someone point me in the right direction as to how to get the result required?

Cheers,
Matt

  • 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-05-17T01:43:09+00:00Added an answer on May 17, 2026 at 1:43 am
    var target = lst.Where(i => i.start <= DateTime.Now && i.end > DateTime.Now).OrderByDescending(i => i.start).First()
    

    Eh… not much else to say.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some models; Vocabularies (tags lists), Labels (tags) and different articles types. These
I have looked all of the place for this and I can't seem to
I am writing an application that converts an ajax xml response into html using
Could someone please explain to me why I'm getting an ActionView::TemplateError when I try
I wonder if someone can help me - I've been programming VB.Net for a
Apologies for my longest question on SO ever. I'm trying to interface with a
When I install things into a virtualenv using pip I often see the message
A nice chap called Darin kindly provided me with some code in order for
I am seeing a redirect loop from our production servers when we enable the
I've seen a few questions and answers on SO suggesting that MD5 is less

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.