calculate day's between two dates

T

Tom

Hello, please help me, I need two write a C++ program that can
calculate the number of days between two dates.
 
T

Tomás

Tom posted:
Hello, please help me, I need two write a C++ program that can
calculate the number of days between two dates.



Step 1: Write the code

Step 2: Get a compiler

Step 3: Compile it


There's bucket-loads of reusable code out there for doing this, but I
presume you're some sort of student and you have to do it all by yourself
so that you learn from it.


-Tomás
 
J

Jacek Dziedzic

Tom said:
Hello, please help me, I need two write a C++ program that can
calculate the number of days between two dates.

What problem did you encounter then? I suppose you did
start on it, right?

- J.
 
O

osmium

Tom said:
Hello, please help me, I need two write a C++ program that can
calculate the number of days between two dates.

Presuming this is a student exercise.....

Top down design is usually preferred but in this case I think it would be OK
to do bottom up. IOW, it isn't really design, it's a Topsy like growth from
the bottom up. You can surely do that for two dates in the same month,
right? Do that. Then consider adjacent months. where neither one of them
is February. Then allow for intervening months in the same year. Then
different years where neither year is a leap year. Then handle leap years
properly. Look in a good dictionary, the leap year rule might have more
rules than you know about.

After completing something like this sequence you will have learned a lot
and you can throw all that code away and write a nice pretty program that
does what you have been asked to do.

If this is not a student exercise, look up Julian day number.
 
O

osmium

Neil Cerutti said:
Or difftime.

I wouldn't recommend that, it only works for a restricted set of dates. A
baby boomer couldn't figure out how old he was in days.
 
D

Diego Martins

Tom said:
Hello, please help me, I need two write a C++ program that can
calculate the number of days between two dates.

pay me and I'll do it for you :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,825
Latest member
VernonQuy6

Latest Threads

Top