这种情况用strcmp(str1,str2)最合适了。

解决方案 »

  1.   

    要想算时间差,恐怕得自己写算法,算天数的算法我过去有,不过丢了,不难,我现在贴出来计算时间的算法,大概是先将时间化为秒,计算后再化回来,转化代码如下:
    unsigned long strtosec(CString* lpstrTime)
    {
    //If parameter CString is null then return -1;
    if(lpstrTime->GetLength()<=0)
    {
    return -1;
    } //Define three CString variables for store hour, minute,
    //and s in string fromat
    CString strHour, strMinute, strSecond; //Define tree integer variables for stroe ... in UINT format
    UINT dwHour, dwMinute, dwSecond; //Define a unsignd long variable for stroe conver result
    unsigned long ulResult; //Extracts hour, minute, and second in the time CString,
    //and store to three CString that define upon
    strSecond=lpstrTime->Right(2);
    strMinute=lpstrTime->Mid(5,2);
    strHour=lpstrTime->Left(4); //Do data Convertion
    dwHour=atoi(strHour);
    dwMinute=atoi(strMinute);
    dwSecond=atoi(strSecond); //Count Time
    ulResult=dwHour*3600+dwMinute*60+dwSecond; //return
    return ulResult;
    }CString sectostr(unsigned long ulSecond)
    {
    if(ulSecond>35999999 || ulSecond<0)
    {
    return "";
    } //Define three UINT variables and stree CString variables
    UINT dwHour, dwMinute, dwSecond; char* tempHour=new char[5];
    char* tempMinute=new char[3];
    char* tempSecond=new char[3]; CString strHour,strMinute,strSecond,strResult; //Count the hour minute, and second
    dwHour=int(ulSecond/3600);
    dwMinute=int((ulSecond%3600)/60);
    dwSecond=ulSecond%3600%60; //Convert hour, minute, and second to char from UINT
    itoa(dwHour, tempHour, 10);
    itoa(dwMinute, tempMinute, 10);
    itoa(dwSecond, tempSecond, 10); //Conver char to CString
    strHour=tempHour;
    strMinute=tempMinute;
    strSecond=tempSecond; //Format the time CString
    while(strHour.GetLength()<4)
    {
    strHour='0'+strHour;
    }
    if(strMinute.GetLength()<2)
    {
    strMinute='0'+strMinute;
    }
    if(strSecond.GetLength()<2)
    {
    strSecond='0'+strSecond;
    } strResult=strHour+':'+strMinute+':'+strSecond; //Release memory
    delete []tempHour;
    delete []tempMinute;
    delete []tempSecond; return strResult;
    }
      

  2.   

    对不起又忘了这个/*******************感谢关注*****************/
    ////////////////////Creamdog//////////////////
      

  3.   

    CTimeSpan,和COleDataTimeSpan 类专门用于此项计算。参考以下程序。细节可查MSDN.CString TimeStartStr = "1978-04-25 23:59:59";
    CString TimeEndStr = "1978-04-25 00:01:03";
    int year = 0;
    int month = 0;
    int day = 0;
    int hour = 0;
    int minute = 0;
    int second = 0;
    year = atoi(TimeStartStr );
    TimeStartStr.Delete(5);
    month = atoi(TimeStartStr);
    ......
    COleDateTime tTimeStart(hour....);
    .....
    COleDataTime tTimeEnd(...);
    COleDateTimeSpan span = tTimeEnd - tTimeStart;
    ............