question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

getMonthsBetween inconsitency

See original GitHub issue

I’m confused to the fact why this returns two separate results.

> var now = new Date()
> var twoMonths = new Date().addMonths(2)
> now.getMonthsBetween(twoMonths)
2.033333333333333
> twoMonths.getMonthsBetween(now)
1.0333299999999999

I assume they’d be the same with a result of 2.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
JerrySievertcommented, Apr 13, 2016

That’s a darned good question.

1reaction
JerrySievertcommented, Apr 24, 2016

it was actually done 6 days ago, but i just found that i hadn’t hit “comment” on the comment.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Difference between 2 calendar instances giving inconsistent ...
I'm using jdk 1.7 and using the Calendar class to calculate the difference between 2 dates. I'm using the below code but it...
Read more >
GNU Date: inconsistency calculating number of days between ...
It seems that up to March I get the expected answer (i.e., I get Nov 20 in the fourth command), but from April...
Read more >
Inconsistency between addMonths & differenceInMonths for ...
There is inconsistency in functions within date-fns that deal with months. We should expect differenceInMonths(addMonths(x, 1), ...
Read more >
How should I calculate my income if it's inconsistent ... - Upsolve
How should I calculate my income if it's inconsistent from month to month? · There are two different times that you have to...
Read more >
How to count number of calendar months between dates
I am trying to calculate the number of calendar months between two dates. My current formula is: =DATEDIF(EOMONTH(Date1), EOMONTH(Date2), ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found