COleDateTimeSpan oneDay(1);
COleDateTime toDay = COleDateTime::GetCurrentTime();
COleDateTime yestoDay = toDay - oneDay;
AfxMessageBox(yestoDay.Format());

解决方案 »

  1.   

    更正一下:
    COleDateTimeSpan oneDay(1.0);
      

  2.   

    long nt;
    time (&nt);
    nt = nt-24*60*60;
    struct tm *t;
    t = localtime(&nt);
    char szTime[20];
    sprintf(szTime,
        "%04d%c%02d%c%02d%c%02d%c%02d%c%02d",
    t->tm_year+1900,
                '-',
    t->tm_mon+1,
    '-',
    t->tm_mday,
    ' ',
    t->tm_hour,
    ':',
    t->tm_min,
    ':',
    t->tm_sec
    );
      

  3.   

    只有日期没有时间的程序  
    CString   str;   
      SYSTEMTIME   time;   
      ::GetLocalTime  (&time);   
      str.Format   ("%d-%d-%d",time.wYear,time.wMonth,time.wDay-1);   
      AfxMessageBox(str);
    给分吧,哈哈