Yesterday - C++ Builder

C++ Builder 参考手册 ➙ System::Dateutils ➙ Yesterday


获取昨天的日期

头文件:#include
命名空间:System::Dateutils
函数原型:

System::TDateTime __fastcall Yesterday(void);

参数:

  • 无;

返回值:

  • 获取昨天的日期,时间部分等于 0,即 00:00:00;
  • 由于日期时间类型的变量值是按照天数表示的,所以 Yesterday 就相当于函数 Today 或 Date 得到的数值 - 1

例:测试和比较函数 Now、Date、Time、DateOf、TimeOf、Today、Yesterday、Tomorrow:

#include 
void __fastcall TForm1::Button1Click(TObject *Sender)
{
    Sysutils::FormatSettings.ShortDateFormat = L"yyyy'年'mm'月'dd'日'";
    Sysutils::FormatSettings.LongTimeFormat = L"hh:nn:ss";

    Memo1->Lines->Add(Sysutils::Now());
    Memo1->Lines->Add(Dateutils::DateOf(Sysutils::Now()));
    Memo1->Lines->Add(Sysutils::Date());
    Memo1->Lines->Add(Dateutils::TimeOf(Sysutils::Now()));
    Memo1->Lines->Add(Sysutils::Time());
    Memo1->Lines->Add(Dateutils::Today());
    Memo1->Lines->Add(Dateutils::Today()-1);
    Memo1->Lines->Add(Dateutils::Yesterday());
    Memo1->Lines->Add(Dateutils::Today()+1);
    Memo1->Lines->Add(Dateutils::Tomorrow());
}

相关:

  • System::Dateutils::Today
  • System::Dateutils::Yesterday
  • System::Dateutils::Tomorrow
  • System::Dateutils::DateOf
  • System::Dateutils::TimeOf
  • System::Dateutils::IsToday
  • System::Dateutils::IsSameDay
  • System::Dateutils
  • System::Sysutils::CurrentYear
  • System::Sysutils::Date
  • System::Sysutils::Now
  • System::Sysutils::Time
  • System::Sysutils

C++ Builder 参考手册 ➙ System::Dateutils ➙ Yesterday

你可能感兴趣的:(Yesterday - C++ Builder)