0
votes

Possible Duplicate:
Checking two TDateTime variables

I am having trouble calculating the difference between two dates and then displaying the difference. I have posted a previous question.

I am after help with the replaceTime function. I am not sure how/why I need to use this.

Here is my code:

TDateTime testFirstDate("11/09/2012");
TDateTime testFirstTime("14:00");

TDateTime testSecondDate("12/09/2012");
TDateTime testSecondTime("16:00");

TDateTime testCombined1 = ReplaceTime(testFirstDate,testFirstTime);
TDateTime testCombined2 = ReplaceTime(testSecondDate,testSecondTime);

TDateTime testDateDifference = testCombined2 - testCombined1;

std::cout << testDateDifference;
1
You do not need to repost the same question more than once: Checking two TDateTime variables - Adriano Repetti
And your problem/question is? - StoryTeller - Unslander Monica
It looks to me as if ReplaceTime is being used to combine a date and a time. You need to combine testFirstDate and testFirstTime and also testSecondDate and testSecondTime before you find the difference, no? - john
Yes. Basically, I am wanting to know if the second time and date is later than the first time and date. - Darryl Janecek

1 Answers

0
votes

Your code doesn't make sense. The difference of two dates is never a new date!

I suspect that this part is wrong:

TDateTime testDateDifference = testCombined2 - testCombined1;

The difference of two dates is a period of time--a time span (usually in seconds). Did you write the implementation for TDateTime yourself?