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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T04:51:34+00:00 2026-05-28T04:51:34+00:00

My question is. Why this bug only happen when I choose CheckIn_Date in August

  • 0

My question is. Why this bug only happen when I choose CheckIn_Date in August and September?

I have a project using ASP.NET MVC 3 and using jQuery for date picker. Lets say that I have 3 textboxes named CheckIn_Date, CheckOut_Date (this two using datepicker) and Days in my view.

When i set Days = 3 then I choose CheckIn_Date = 2012-01-01, my CheckOut_Date will automatically count the days and set the value to 2012-01-03.

All goes as I expect, until I choose 2012-08-01 in my CheckIn_Date and set the Days = 3. My CheckOut_Date value is not 2012-08-04 but 2012-12-04. This only happens when I choose my CheckIn_Date in August and September. Choosing any other month give me what I expect for my CheckOut_Date.

Here is my code:

$("input[data-datepicker='true']").change(function () {
    var id = $(this).attr("name");
    var days = parseInt($("#maxProgramDays").val());
    //var o = new Date();
    var val = $(this).val();
    var s = val.split("-");
    var x = [];
    var thisDate = new Date();
    thisDate.setFullYear(parseInt(s[0]), parseInt(s[1]) - 1, parseInt(s[2]));

    //alert(thisDate.toDateString())
    if (id == "Reservation[0].CheckIn_Date") {
        thisDate.setDate(thisDate.getDate() + days);

        x['year'] = thisDate.getFullYear();
        x['month'] = m2d(thisDate.getMonth() + 1);
        x['day'] = m2d(thisDate.getDate());

        $("input[name='Reservation[0].CheckOut_Date']").val(x['year'] + '-' + x['month'] + '-' + x['day']);

        //alert(thisDate.toDateString())
    }

    if (id == "Reservation[0].CheckOut_Date") {
        thisDate.setDate(thisDate.getDate() - days);

        x['year'] = thisDate.getFullYear();
        x['month'] = m2d(thisDate.getMonth() + 1);
        x['day'] = m2d(thisDate.getDate());

        $("input[name='Reservation[0].CheckIn_Date']").val(x['year'] + '-' + x['month'] + '-' + x['day']);

        //alert(thisDate.toDateString())
    }

Here is my View:

<div class="display-label">Program Days</div>
<div class="display-field"><span id="pDays"></span></div>

<div class="editor-label">@Html.LabelFor(model => model.Reservation[0].CheckIn_Date)</div>
<div class="editor-field reserveDate">
    @Html.Datepicker("Reservation[0].CheckIn_Date", "")
    @Html.ValidationMessageFor(model => model.Reservation[0].CheckIn_Date)
</div>

<div class="editor-label">@Html.LabelFor(model => model.Reservation[0].CheckOut_Date)</div>
<div class="editor-field reserveDate">
    @Html.Datepicker("Reservation[0].CheckOut_Date", "")
    @Html.ValidationMessageFor(model => model.Reservation[0].CheckOut_Date)
</div>
  • 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-28T04:51:35+00:00Added an answer on May 28, 2026 at 4:51 am

    The problem was out of this world. Here it goes when you give date as 2010-08-01, in your thisDate.setFullYear(parseInt(s[0]), parseInt(s[1]) - 1, parseInt(s[2])); function, parseInt(s[1]) at runtime look likes parseInt("08"), and here it goes wrong

    parseInt(“08”) returns Zero, it is same for parseInt(“09”)

    Reason

    Both parseInt(’08’) and parseInt(’09’) return zero because the function tries to determine the correct base for the numerical system used. In Javascript numbers starting with zero are considered octal and there’s no 08 or 09 in octal, hence the problem.

    How to fix it

    To fix this just add the second parameter for parseInt, the base to be used for the conversion. The correct calls should be parseInt(“08”, 10) and parseInt(“09”, 10).

    So your code will become

    thisDate.setFullYear(parseInt(s[0], 10), parseInt(s[1], 10) - 1, parseInt(s[2], 10));
    

    This will work for you.

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

Sidebar

Related Questions

Edited Question: This should be clear. using System; namespace UpdateDateTimeFields { class Program {
Weird question this, going round in circles. I have 2 pages. Page 1. Has
hopefully a pretty simple question this time. I have a Select method in a
I have a schema like this <h1> 5/2009 <br/> Question: This is the question
This question might be naive as I'm new to ColdFusion programming. I have a
I have the same problem as the user in this question , which is
Update: A sample project reproducing this bug can be found here at Microsoft Connect
I have a ComboBox which I cannot bind directly to (due to this bug
A rather specific question I realize, but I can't pinpoint this bug to either
This is a WinForm application question in .net. It is about MDI form. I

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.