471,585 Members | 1,594 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,585 software developers and data experts.

calculate day's between two dates

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

Mar 16 '06 #1
6 7897
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
Mar 16 '06 #2
Tom wrote:
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.
Mar 16 '06 #3
"Tom" writes:
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.
Mar 16 '06 #4
On 2006-03-16, osmium <r1********@comcast.net> wrote:
"Tom" writes:
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.....
<snip>
If this is not a student exercise, look up Julian day number.


Or difftime.

--
Neil Cerutti
Low Self-Esteem Support Group will meet Thursday at 7 to 8:30
p.m. Please use the back door. --Church Bulletin Blooper
Mar 16 '06 #5
"Neil Cerutti" wrote:
If this is not a student exercise, look up Julian day number.


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.
Mar 16 '06 #6

Tom wrote:
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 :)

Mar 16 '06 #7

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

13 posts views Thread by David Gray | last post: by
4 posts views Thread by Manny Chohan | last post: by
7 posts views Thread by Sam | last post: by
9 posts views Thread by Pierre Quentel | last post: by
reply views Thread by XIAOLAOHU | last post: by
reply views Thread by Anwar ali | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.