473,396 Members | 1,849 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 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 8026
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
by: David Gray | last post by:
Greetings all, Quick newbie type question: I would like to be able to trap non-numerical data entered into a textbox via CTRL+C and/or Shift+Insert. I realise that this data can be...
4
by: Manny Chohan | last post by:
Hi Can anyone tell me how i can calculate yesterday date using asp? Thanks manny
6
by: carl.barrett | last post by:
Hi, I have a continuous form based on a query ( I will also be creating a report based on the same query). There are 2 fields: Date Obtained and Date Of Expiry I want a further 3 columns...
3
by: | last post by:
Hello, I am hoping someone else has thought about a date time calculation i need to perform. I would like to be able to calculate the number of "working minutes" between 2 dates, given my...
7
by: Sam | last post by:
Hi, I use C# in my ASP.NET projects. Here's what I need to do: I want to add x business days to a given date i.e. add 12 business days to today's date. What is the best, fastest and most...
7
by: walt | last post by:
Hello, I have been trying to calculate the difference between two date and display the difference in hours and minutes (HH:MM). I can't get it calculate properly and I can't hours and minutes to...
9
by: Pierre Quentel | last post by:
Hi all, I have searched in the standard distribution if there was a function to return the difference between 2 dates expressed like an age : number of years, of months and days. The difference...
5
by: Mike | last post by:
I use c#, V2005 How I can get difference between two dates and get value in month(s) I had found some solutions but it is not exactly what I need. private static int...
5
FishVal
by: FishVal | last post by:
IMHO, the following is not a how-to-do instruction to solve a particular problem but more a concept-proof stuff demonstrating possibilities of SQL. So, let us say the problem is to calculate...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.