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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T15:35:39+00:00 2026-05-16T15:35:39+00:00

I am stuck for sometime now, now need your help. I want to display

  • 0

I am stuck for sometime now, now need your help.

I want to display in a dropdown only fourth Sunday of each month, say from 1-Sep-2010 to 31-Aug-2011

I only want fourth Sunday in dropdown list, how to do it using asp.net C#

Regards

  • 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-16T15:35:41+00:00Added an answer on May 16, 2026 at 3:35 pm

    Here is an approach that uses a little LINQ and the knowledge that the fourth Sunday will occur between the 22nd and 28th of a month, inclusive.

    DateTime startDate = new DateTime(2010, 9, 1);
    DateTime endDate = startDate.AddYears(1).AddDays(-1);
    
    List<DateTime> fourthSundays = new List<DateTime>();
    
    DateTime currentDate = startDate;
    while (currentDate < endDate)
    {
        // we know the fourth sunday will be the 22-28
        DateTime fourthSunday = Enumerable.Range(22, 7).Select(day => new DateTime(currentDate.Year, currentDate.Month, day)).Single(date => date.DayOfWeek == DayOfWeek.Sunday);
        fourthSundays.Add(fourthSunday);
        currentDate = currentDate.AddMonths(1);
    }
    

    You can then bind that List<DateTime> to the dropdown or skip the list itself in favor of adding the items as you generate them to the dropdown, like below.

    yourDropdown.Items.Add(new ListItem(fourthSunday.ToString()));
    

    For giggles, you can do the whole thing in a LINQ statement and skip (most of) the variables.

    DateTime startDate = new DateTime(2010, 9, 1); 
    IEnumerable<DateTime> fourthSundays =
        Enumerable.Range(0, 12)
        .Select(item => startDate.AddMonths(item))
        .Select(currentMonth =>
            Enumerable.Range(22, 7)
            .Select(day => new DateTime(currentMonth.Year, currentMonth.Month, day))
            .Single(date => date.DayOfWeek == DayOfWeek.Sunday)
        );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have now been stuck at this for some time so I though to
I'm very stuck on creating a piece of perl i need. I have a
I have been stuck with this issue now all morning. I actually saw this
I'm stuck with a problem considering my Display class, which extends Canvas. A single
I have been stuck with this problem for quite some time now and i
I have been researching for sometime now regarding the process to install android sdk
I am stuck on the same code for quit some time now. I am
I've been following this forum for sometime now but officially registered today. I'm a
I am having this issue I have been struggling with for sometime and now
I'm stuck on a problem for hours now and having read everything about this

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.