function WeekOfTheMonth(const AValue: TDateTime): Word; function WeekOfTheMonth(const AValue: TDateTime; var AYear, AMonth: Word): Word;
extern DELPHI_PACKAGE System::Word __fastcall WeekOfTheMonth(const System::TDateTime AValue)/* overload */;
Returns the week of the month represented by a TDateTime value.
AYear and AMonth return the year and month in which WeekOfTheMonth occurs. Note that these values may not be the same as the year and month of AValue. This is because the first week of a month is defined as the first week with four or more days in that month. Thus, if the first day of the month is a Friday, Saturday, or Sunday, the first one, two, or three days of the month are defined as belonging to the last week of the previous month. Similarly, if the last day of the month is a Monday, Tuesday, or Wednesday, then the last one, two, or three days of the month are defined as belonging to the first week of the next month.
Tip: To count weeks based on the weekday of the date/time value, use the NthDayOfWeek function instead. For example, if AValue represents a Saturday that is the first day of a month, WeekOfTheMonth returns 5 (or maybe 4), indicating the last week of the previous month, while NthDayOfWeek returns 1 if AValue is the first Saturday in the month.
Note: WeekOfTheMonth uses the ISO 8601 standard definition of a week. That is, a week is considered to start on a Monday and end on a Sunday.