Hi all!
I have this small function that checks a day is between 2 dates.
I give for example as starting date 20/04/2011 and as end date 25/04/2011.
Then I check if the date 22/04/2011 is in between but the operator >= and the <= are not working very well.
Syear = 2011, Eyear = 2011, year = 2011;
Smonth = 04, Emonth = 04, month = 04;
Sday = 20, Eday = 25, day = 22;
if((Syear() >= year) and (Eyear() <= year)){
cout << "Year match" << endl;
if((Smonth() >= month) and (Emonth() <= month)){
cout << "Month match" << endl;
if((_Temp->getSday() >= day) and (_Temp->getEday() <= day)){
cout << "Day match" << endl;
}
}
}
if((Syear() >= year) and (Eyear() <= year)){
cout << "Year match" << endl;
if((Smonth() >= month) and (Emonth() <= month)){
cout << "Month match" << endl;
if((_Temp->getSday() >= day) and (_Temp->getEday() <= day)){
cout << "Day match" << endl;
}
}
}
To copy to clipboard, switch view to plain text mode
output of the program:
Year Match
Month Match
but day doesn't
then I added this:
if(Sday() >= day) cout << "day >=" << endl;
if(Eday() <= day) cout << "day <=" << endl;
if(Sday() >= day) cout << "day >=" << endl;
if(Eday() <= day) cout << "day <=" << endl;
To copy to clipboard, switch view to plain text mode
with:
Sday = 20, Eday = 25, day =22;
No output
with:
Sday = 20, Eday = 25, day =20;
output is:
day >=
and with:
Sday = 20, Eday = 25, day =25;
output is:
day <=
that means it only check for days = to Sday or Eday.
What is wrong?
thanks
Bookmarks