C++ Builder 参考手册 ➙ System::Sysutils ➙ DecodeDate
从日期时间类型数值里面解析出年、月、日
头文件:#include <System.SysUtils.hpp>
命名空间:System::Sysutils
函数原型:
void __fastcall DecodeDate(const System::TDateTime DateTime, System::Word &Year, System::Word &Month, System::Word &Day);
参数:
- DateTime:日期时间类型变量;
- Year:返回年,1 ~ 9999
- Month:返回月,1 ~ 12
- Day:返回日,1 ~ 31
返回值:
- 无,解析结果通过参数 Year, Month, Day 返回。
例:
void __fastcall TForm1::Button1Click(TObject *Sender)
{
System::TDateTime dt = Sysutils::Now();
unsigned short uYear, uMonth, uDay;
Sysutils::DecodeDate(dt, uYear, uMonth, uDay);
UnicodeString s;
s.sprintf(L"今天日期:%u 年 %u 月 %u 日", uYear, uMonth, uDay);
Memo1->Lines->Add(s);
}
运行结果:
相关:
- System::Dateutils::DecodeDateTime
- System::Dateutils::EncodeDateTime
- System::Dateutils::TryEncodeDateTime
- System::Dateutils::DateTimeToUnix
- System::Dateutils::UnixToDateTime
- System::Dateutils::YearOf
- System::Dateutils::MonthOf
- System::Dateutils::DayOf
- System::Dateutils::DayOfTheWeek
- System::Dateutils::DayOfTheMonth
- System::Dateutils::DayOfTheYear
- System::Dateutils::HourOf
- System::Dateutils::MinuteOf
- System::Dateutils::SecondOf
- System::Dateutils::MilliSecondOf
- System::Dateutils
- System::Sysutils::DecodeDate
- System::Sysutils::DecodeDateFully
- System::Sysutils::DecodeTime
- System::Sysutils::EncodeDate
- System::Sysutils::EncodeTime
- System::Sysutils::TryEncodeDate
- System::Sysutils::TryEncodeTime
- System::Sysutils::TryStrToDate
- System::Sysutils::TryStrToDateTime
- System::Sysutils::TryStrToTime
- System::Sysutils::FormatDateTime
- System::Sysutils::CurrentYear
- System::Sysutils::Now
- System::Sysutils::Date
- System::Sysutils::Time
- System::Sysutils
C++ Builder 参考手册 ➙ System::Sysutils ➙ DecodeDate