cmpDate(char *date1, char *date2) { //date1>date2=-1 date1=date2=0 date1IndexOf("/"); int i2=dt1->LastIndexOf("/"); int i3=dt2->IndexOf("/"); int i4=dt2->LastIndexOf("/"); int dt1month=System::Convert::ToInt32(dt1->Substring(0,i1)); int dt1day=System::Convert::ToInt32(dt1->Substring(i1+1,i2-i1-1)); int dt1year=System::Convert::ToInt32(dt1->Substring(i2+1)); int dt2month=System::Convert::ToInt32(dt2->Substring(0,i3)); int dt2day=System::Convert::ToInt32(dt2->Substring(i3+1,i4-i3-1)); int dt2year=System::Convert::ToInt32(dt2->Substring(i4+1)); if(dt1year>dt2year) return -1; else { if(dt1year==dt1year) { if(dt1month>dt2month) return -1; else if(dt1month==dt2month) { if(dt1day>dt2day) { return -1; } if(dt1day<dt2day) return 1; } } } return 1; }
Friday, September 9, 2011
C++ Date Comparison Function
Hi Readers, This is a method coded by me in my first year to compare two date values in char array and give the comparison in integer.
Labels:
c++,
comparison,
date
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment