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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T06:48:15+00:00 2026-05-28T06:48:15+00:00

I am trying to do a date calculation in javascript that matches one in

  • 0

I am trying to do a date calculation in javascript that matches one in excel.

//Excel 
=(EDATE(DATE(2000,6,1),60)-DATE(2012,1,20))

This gives a result of -2424

So I try to do the same calculation in javascript with the following

//Javascript -  using datejs library
a = Date.parse('2000/06/01').addMonths(60);
b = Date.parse('2012/01/20');
a.setHours(12,0,0);
b.setHours(12,0,0);
span = new TimeSpan(a - b);
console.log(span.getDays());

This gives a result of -2423

I can’t see why i am losing a day.
Can anyone shed light on how this could be happening.

Cheers for any help in advance. 🙂

  • 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-28T06:48:15+00:00Added an answer on May 28, 2026 at 6:48 am

    If nothing else, two leapseconds occured in 2005 and 2008 (Both on Dec 31st), which either app could be taking into account. You’ve explicitly set your JS dates to “noon”, but specified no times for Excel, so it’s probably defaulting to midnight, which is when the leapseconds occur. That’d make your Excel date/times be 2 seconds off from the JS calcs, and could cross the midnight border, accounting for your one missing day.

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

Sidebar

Related Questions

I am trying to set a javascript date so that it can be submitted
I'm trying to do a very basic date-difference calculation with javascript, but am getting
So I'm trying to convert this Excel cell calculation into C#, but I can't
Im trying to use Date Formatters (NSDateFormatter), but I keep getting this error: Program
Trying to display current time with PHP (using this ): $date = date('m/d/Y h:i:s
I'm trying to set up a cube calculation. My current remit is that I
I'm trying to write a query that will return data grouped by date ranges
I'm fairly new to JavaScript and am trying to write some code that lists
i am trying to get date from my implementation of jquery date picker, add
I'm getting an InstantiationException when trying to map Date -> Calendar. Simple test follows:

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.