Hello, please help me, I need two write a C++ program that can
calculate the number of days between two dates. 6 8055
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
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.
"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.
On 2006-03-16, osmium <r1********@com cast.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
"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.
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 :) This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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 validated using the TEXTn_validate
event but I would like to stop the user before it gets that far.
|
by: Manny Chohan |
last post by:
Hi Can anyone tell me how i can calculate yesterday date using asp?
Thanks
manny
|
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 to the right of these 2 fields to show the
|
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 working week definition.
Lets say I have a working week definition of Monday through Friday, 9 am to
5 pm.
Date1 = January 1st, 2005 at 8 am
|
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 efficient way for me to do this?
--
Thanks,
Sam
| |
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 display.
I tried "results=enddate-startdate" dates have month, day, year,and time of day. After this calculation I end up with no results.
Any help would be appreciated.
Walt
|
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 between datetime
instances returns a timedelta object that gives a number of days, but
not an age
So is there such a function somewhere ? If not, for what reason, since
it's a rather usual task
|
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 monthDifference(DateTime startDate, DateTime
endDate)
{
int monthsApart = 12 * (startDate.Year - endDate.Year) +
|
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 business days count which is defined as count of days (optionally inclusive in the current implementation) excluding weekend days and holidays.
Let us say periods to calculate are stored in table associated with contacts.
keyPeriodID -...
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
| |
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |