- StartOfAMonth - C++ Builder
- C++ Builder 的字符串类型、字符类型、字符编码
- TInterfacedPersistent::AfterCons
- TInterfacedPersistent::QueryInte
- TInterfacedPersistent::~TInterfa
- TInterfacedPersistent::TInterfac
- TThread::NameThreadForDebugging
- TThread::Suspended - C++ Builder
- TThread::Terminate - C++ Builder
- TInterfacedObject - C++ Builder
C++ Builder 参考手册 ➙ System::Dateutils ➙ StartOfAMonth
某个月的开始时间,这一个月的 1 日 00:00:00.000
头文件:#include <System.DateUtils.hpp>
命名空间:System::Dateutils
函数原型:
System::TDateTime __fastcall StartOfAMonth(const System::Word AYear, const System::Word AMonth);
参数:
- AYear:年,1 - 9999;
- AMonth:月,1 - 12;
返回值:
- AYear 年 AMonth 月的开始时间,这一个月的 1 日 00:00:00.000;
- 比较函数 StartOfAMonth 和 StartOfTheMonth:
• StartOfAMonth 的参数是整数年、月;
• StartOfTheMonth 的参数是日期时间;
只要这两个函数参数的年月和日期的年月相同,返回值就相同。
例:
#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)));
}
运行结果:
![](https://img.haomeiwen.com/i19822773/b92f767f77c92c76.png)
相关:
- 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 ➙ StartOfAMonth
网友评论