C++ Builder 參考手冊 ? System::Dateutils ? EndOfAMonth
某個月的開始時間,這一個月的最后一天 23:59:59.999
頭文件:#include <System.DateUtils.hpp>
命名空間:System::Dateutils
函數(shù)原型:
System::TDateTime __fastcall EndOfAMonth(const System::Word AYear, const System::Word AMonth);
參數(shù):
- AYear:年无畔,1 - 9999啊楚;
- AMonth:月,1 - 12浑彰;
返回值:
- AYear 年 AMonth 月的開始時間恭理,這一個月最后一天的 23:59:59.999;
- 在程序里面郭变,通常判斷小于下個月1日00:00:00颜价,而不是判斷小于等于這個月的末尾時間;
- 比較函數(shù) EndOfAMonth 和 EndOfTheMonth:
? EndOfAMonth 的參數(shù)是整數(shù)年诉濒、月周伦;
? EndOfTheMonth 的參數(shù)是日期時間;
只要這兩個函數(shù)參數(shù)的年月和日期的年月相同未荒,返回值就相同专挪。
例:
#include <System.DateUtils.hpp>
void __fastcall TForm1::Button1Click(TObject *Sender)
{
TDateTime dt = Sysutils::Now();
Memo1->Lines->Add(FormatDateTime(L"yyyy/mm/dd hh:nn:ss.zzz", dt));
Memo1->Lines->Add(FormatDateTime(L"yyyy/mm/dd hh:nn:ss.zzz", StartOfTheMonth(dt)));
Memo1->Lines->Add(FormatDateTime(L"yyyy/mm/dd hh:nn:ss.zzz", EndOfTheMonth(dt)));
unsigned short iYear = Dateutils::YearOf(dt);
unsigned short iMonth = Dateutils::MonthOf(dt);
Memo1->Lines->Add(String().sprintf(L"%d年%d月", iYear, iMonth));
Memo1->Lines->Add(FormatDateTime(L"yyyy/mm/dd hh:nn:ss.zzz", StartOfAMonth(iYear,iMonth)));
Memo1->Lines->Add(FormatDateTime(L"yyyy/mm/dd hh:nn:ss.zzz", EndOfAMonth(iYear,iMonth)));
}
運行結(jié)果:
相關(guān):
- System::Dateutils::StartOfTheYear
- System::Dateutils::EndOfTheYear
- System::Dateutils::StartOfTheMonth
- System::Dateutils::EndOfTheMonth
- System::Dateutils::StartOfTheWeek
- System::Dateutils::EndOfTheWeek
- System::Dateutils::StartOfTheDay
- System::Dateutils::EndOfTheDay
- System::Dateutils::StartOfAYear
- System::Dateutils::EndOfAYear
- System::Dateutils::StartOfAMonth
- System::Dateutils::EndOfAMonth
- System::Dateutils::StartOfAWeek
- System::Dateutils::EndOfAWeek
- System::Dateutils::StartOfADay
- System::Dateutils::EndOfADay
- System::Dateutils::DaysInYear
- System::Dateutils::DaysInAYear
- System::Dateutils::DaysInMonth
- System::Dateutils::DaysInAMonth
- System::Dateutils::WeeksInYear
- System::Dateutils::WeeksInAYear
- System::Dateutils
C++ Builder 參考手冊 ? System::Dateutils ? EndOfAMonth