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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T05:32:34+00:00 2026-06-07T05:32:34+00:00

I have an ASP.Net calendar feature which allows users to add events and configure

  • 0

I have an ASP.Net calendar feature which allows users to add events and
configure whether or not they repeat at various frequencies (i.e, daily,
weekly, monthly, Sat/Sun, etc.). What I’m looking for is some C# code that
will calculate a date of “Every Other Week” based on a starting date and
ending date.

Example: If a user enters an event dated July 7, 2012 and would like it
to repeat every other week until July 31, 2012, the code will return the
following dates:

July 7, 2012
July 14, 2012
July 21, 2012
July 28, 2012

and one more functionality is there to selection of days in week(i.e, mon,tue,wed..).

Any help would be greatly appreciated.

  • 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-07T05:32:36+00:00Added an answer on June 7, 2026 at 5:32 am

    You probably want a function that takes two DateTime objects (The start date and the end date) and some interval in between events. You can then use the DateTime.AddDays(double value) function to generate all of the in-between dates. To get every other week, your interval would be 14. You would keep adding 14 days until the date you got was after your end date.

    //Create a list of DateTimes including the start date, with the specified
    //number of days in between each item in the list.
    public static IList<DateTime> GetRepeatingEvents(DateTime start, DateTime end, int intervalInDays)
    {
      List<DateTime> allEvents = new List<DateTime>();
      allEvents.Add(start); //Make sure the start date is included in the list of dates!
    
      var tempDate = start;
      while (tempDate <= end) //Less than or Equals means the end date will be added as well
      {
        tempDate = tempDate.AddDays(intervalInDays);
        allEvents.Add(tempDate);
      }
      return allEvents;
    }
    

    You’ll need to be a bit careful if your start and end dates contain a Time component as well. For example, if:

    • Your start date was July 7, 2012 10:30 AM
    • Your end date was July 28, 2012 9:00 AM
    • Your interval was one week (7 days)

    Then above function would not include a July 28 date in the list because 21 days after July 7th 10:30 AM is July 28th 10:30 AM which would not satisfy the conditional in while(tempDate <= end) because end occurs at 9:00 AM

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

Sidebar

Related Questions

I've built an ASP.net web application which allows the users to view and make
I tried to configure the Ext.NET asp.net calendar control to view my own events
I have an ASP.Net Calendar control that, on DayRender, loops through a list of
I have 2 asp.net texboxes with calendar extender. I want to find out the
I have an asp.net form that contains some html, 2 controls a calendar from
I have Asp.net website for domain A users with the Integrated Windows Authentication. Now
I have an asp.net calendar control that is used to select a date and
i have added to my page an asp.net calendar control and i would like
I have an asp.net mvc 2.0 application that contains Areas/Modules like calendar, admin, etc...
I have a calendar control on a asp .net webform. In the Pag_Load event

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.