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 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 am new to python, apologies if this has been asked already. Using python
Apologies if this question has been asked before. I'm hoping that someone can step
Apologies if this is a dumb question. In previous ASP.NET projects, I've been using
Apologies if this conflicts with a previous post of mine, but I am pretty
Apologies if the question has already been answered elsewhere but I look around already
Apologies if this has already been asked and answered; I've looked around a bunch
Apologies for the long code post but am wondering if someone can help with
Apologies for a lack of code, but basically I am using the jqModal plugin
Apologies if this is a bit of a simple one, but I'm quite new
Apologies if this is a simple question, but I turn to the wisdom of

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.