Click here to Skip to main content
15,881,757 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How can I understand if a date is bigger then an other? I have thwo dates in ColeDateTime.

What I have tried:

I tried:
ColeDateTime t1;
ColeDateTime t2;

t1>t2;
Posted
Updated 8-Oct-21 7:59am
Comments
PIEBALDconsult 7-Oct-21 11:53am    
"Bigger"? No. "Later"? Maybe.
Doesn't that work?
Member 14594285 7-Oct-21 11:59am    
yes later, sorry..
KarstenK 7-Oct-21 12:02pm    
write a clear answer to close that q&a
Member 14594285 7-Oct-21 12:04pm    
I must understand if date1 is later then an other, if I write date1>date2 it doesn't work.

There is no overload of the greater than operator ibn

See COleDateTime Class | Microsoft Docs[^] for details of the comparison operators.
 
Share this answer
 
v3
Comments
merano99 7-Oct-21 18:17pm    
If I understand the linked documentation correctly, there are COleDateTime Relational Operators

bool operator==(const COleDateTime& date) const throw();
bool operator!=(const COleDateTime& date) const throw();
bool operator<(const COleDateTime& date) const throw();
bool operator>(const COleDateTime& date) const throw();
bool operator<=(const COleDateTime& date) const throw();
bool operator>=(const COleDateTime& date) const throw();
Richard MacCutchan 8-Oct-21 3:46am    
Sorry, I misread the documentation.
Member 14594285 8-Oct-21 3:31am    
I wrote:
COleDateTime aa;
COleDateTime bb;
int t;
aa.SetDate(01, 02, 2021);
aa.SetTime(0, 0, 0);
bb.SetDate(02, 02, 2021);
bb.SetTime(0, 0, 0);

aa.GetStatus();
bb.GetStatus();

BOOL b1;
BOOL b2;
BOOL b3;
b1 = aa == bb; // TRUE
b2 = aa < bb; // FALSE
b3 = aa > bb; //FALSE

so values of b1,b2,b3 are incorrect
merano99 8-Oct-21 14:00pm    
Ok. Then see my solution.
merano99 9-Oct-21 4:09am    
I don't see any reason to cross out the entire solution.
The correct spelling of COleDateTime and the link to the documentation are important parts of the solution.
Member 14594285 wrote:
C++
COleDateTime aa;
aa.SetDate(01, 02, 2021);

You should always check return values, an read the docu.
If you look at the docu you see this:
C++
int SetDate( int nYear, int nMonth, int nDay) throw();

Obviously, it has to go grossly wrong.

And if you had at least evaluated the return value
here of course the error is also visible.
C++
int ret = aa.SetDate(01, 02, 2021);
if(ret != 0) ...
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900