Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
Solved

# Calculate days between two dates

Posted on 1997-03-06
Medium Priority
247 Views
I want to calculate the number of days between two days.
0
Question by:manne
[X]
###### Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

• Help others & share knowledge
• Earn cash & points
1 Comment

LVL 1

Accepted Solution

vanbasco earned 200 total points
ID: 1162274
Well, I suggest you introduce a table containing the number of days for each month, for example days_in_this_month[];

For example, number of days (including both start and end-day) from January 13 to March 7:

int day_number = 0;

for (i=1; i<3;i++)
day_number += days_in_this_month[i];

day_number -= (13-1);
day_number += 7;

//Hope this helps.

0

## Featured Post

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.
###### Suggested Courses
Course of the Month9 days, 19 hours left to enroll