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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T14:24:34+00:00 2026-05-11T14:24:34+00:00

Requirements: Calculate the number of months between two dates: receiveDate and dueDate. Both optimistic

  • 0

Requirements:

  • Calculate the number of months between two dates: receiveDate and dueDate.
  • Both optimistic and pessimistic calculations are needed

Assumptions:

  • dueDate will always be the last day of the month.

I’ve already figured out the pessimistic calculation (meaning a single day overdue counts as a whole month:

if(receiveDate > dueDate)     receiveDate.Month - dueDate.Month + (receiveDate.Year - dueDate.Year) * 12; 

Doing a search on the internet turned up several similar examples to confirm this.

Now my instincts tell me the optimistic calculation will just be the same minus one month but for some reason it just doesn’t feel right. Am I on the right track or am I missing something?

  • 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. 2026-05-11T14:24:34+00:00Added an answer on May 11, 2026 at 2:24 pm

    You’re right; if you’re looking for the number of complete months between the two dates, subtracting 1 (assuming the receiveDate doesn’t fall on the last day of the month, in which case you will have a remainder of 0 days either way) will get you your answer.

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

Sidebar

Related Questions

I'm writing an application that will calculate the distance and cost between two points.
I'm writing a simple but a little specific program: Purpose: calculate number from it's
Given a function zipdistance(zipfrom,zipto) which calculates the distance (in miles) between two zip codes
I have requirement, wherein I have to calculate totals for cash and credit cards
Requirements I would like to keep an audit log of particular events, such as:
Requirements Project should contain 1 main application and some secondary sub applications (which uses
Requirements: free, preferably open-source implemented in one of the .NET managed langs Google found
Requirements : I have a table of several thousand questions. Users can view these
Requirements: On a web page in our web application, we have a requirement to
Some requirements for a mobile chat room: Should be able to work seamlessly with

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.