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 6974385
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T17:13:51+00:00 2026-05-27T17:13:51+00:00

There is a sharepoint list which has 2 columns about date: SchedulingEndDate (can be

  • 0

There is a sharepoint list which has 2 columns about date:

  1. SchedulingEndDate (can be null)
  2. NewsDate (always has value)

I have to get 30 news from that list with this requirements:

  1. if SchedulingEndDate is null, check if (today > NewsDate)
  2. if SchedulingStartDate is not null, check if (today >= NewsDate &&
    today <= SchedulingEndDate)

This is what i wrote:

public static IList<NewsPage> GetNews(int maxNews)
{
    var list = listNews.Select(p => p).
    Where(p => (DateTime)p.NewsDate <= DateTime.Now).CustomWhere().
    OrderByDescending(p => p.NewsDate).Take(maxNews).AsQueryable();
    news = list.ToList();
}

public static IQueryable<NewsPage> CustomWhere(this IQueryable<NewsPage> newsList)
{
    return newsList.Where(p => (p.SchedulingEndDate != null 
    && (DateTime)p.SchedulingEndDate >= DateTime.Now));
}

As expected, it only returns the rows where SchedulingEndDate is not null.

What do you suggest me to do?

  • 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-27T17:13:51+00:00Added an answer on May 27, 2026 at 5:13 pm

    Based on your requirements, I think a Where() clause like this, despite being very ugly, should do the trick:

       list.Where(p => (p.SchedulingEndDate == null && DateTime.Now > p.NewsDate)
                                || (p.SchedulingEndDate != null && p.SchedulingStartDate != null && (DateTime.Now > p.NewsDate && DateTime.Now < p.SchedulingEndDate)));
    

    You could break it into its own function to clean it up a bit.

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

Sidebar

Related Questions

i have a sharepoint custom list and we have 2 columns in there URL
I currently have a normal SharePoint list with about 15 columns or so. I
I have a sharepoint list which has several fields. It seems that when a
I have a list in sharepoint foundation. Each item has a field which is
In SharePoint 2007, there's a top nav that the user can hover over, which
I have a SharePoint server. I am building an rails application which can interact
I have a custom content type in SharePoint which has an approval workflow associated
We have MS Sharepoint -- which isn't all bad for managing a task list.
I have an InfoPath form which has two data connections: Connection to a SharePoint
I have a custom list in which there is one column as employee which

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.