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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T19:18:36+00:00 2026-06-15T19:18:36+00:00

So the user can select 2 different dates, a start date and an end

  • 0

So the user can select 2 different dates, a start date and an end date from 2 calendars, when they click add the dates between&including the dates selected will be added to the Database, each date as a separate record.

This works fine however I don’t want weekends to be added to the Database.

I’ve updated the UI of datepicker http://www.kelvinluck.com/assets/jquery/datePicker/v2/demo/datePickerCustomCellRender.html
but if a user selects fri-mon for example fri,sat,sun and mon will be added to the Database.
I’ve tried to only run the code if datyofweek is not saturday or sunday

 public ActionResult listHolidays(Holiday holiday, int? PersonId, string HolidayDate, string endDate)
        {
            DateTime startDates = Convert.ToDateTime(HolidayDate),
                     endDates = Convert.ToDateTime(endDate);

            while (startDates <= endDates)
            {
                if (startDates.DayOfWeek != DayOfWeek.Saturday || startDates.DayOfWeek != DayOfWeek.Sunday)
                {
                    Holiday holiday1 = new Holiday();
                    holiday1.PersonId = PersonId.Value;
                    holiday1.HolidayDate = startDates;

                    db.Holidays.AddObject(holiday1);
                    db.SaveChanges();


                     startDates = startDates.AddDays(1);
                }
            }

            return RedirectToAction("Index");
        }

any help?
Thanks

  • 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-15T19:18:37+00:00Added an answer on June 15, 2026 at 7:18 pm

    You need to use AND instead of OR:

    if (startDates.DayOfWeek != DayOfWeek.Saturday && startDates.DayOfWeek != DayOfWeek.Sunday)
    

    Your current condition will always be true. If startDates is DayOfWeek.Saturday, it is not DayOfWeek.Sunday and vice versa.

    After that, you need to put the startDates = startDates.AddDays(1); outside the if.

    Otherwise, you would have an endless loop, because as soon as startDates is DayOfWeek.Saturday, it will no longer be incremented.

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

Sidebar

Related Questions

In my app,user can select image from gallery and after that he can zoom
I have the following select list from which the user can select multiple values.
I have a list of videos that a user can select from to watch.
I have a page where the user can select three different appointment days using
I have this PHP page where the user can select and un-select items. The
I have a View where the user can select Basic Configuration and Advanced Configuration
I have a segmented control where the user can select how to order a
I have a dropdown box where the user can select a method to check
There is a common feature of modern browsers where a user can select some
Am working on an PHP application that involves multiple plans a user can select.

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.