function NthDayOfWeek(const AValue: TDateTime): Word;
extern DELPHI_PACKAGE System::Word __fastcall NthDayOfWeek(const System::TDateTime AValue);
Returns which occurrence of its weekday a specified TDateTime value represents.
NthDayOfWeek indicates which occurrence of a weekday within a month the date and time specified by AValue represents. For example, if AValue represents the second Tuesday of the month, NthDayOfWeek returns 2.
Note that this value may differ from the value that the WeekOfTheMonth function returns, because NthDayOfWeek counts every occurrence of the given weekday, while WeekOfTheMonth only counts a week if it includes four or more days in the month. Thus, for example, if AValue represents a Saturday that is the first day of a month, NthDayOfWeek returns 1, while WeekOfTheMonth returns 5 (or maybe 4), indicating the last week of the previous month.
Note: To obtain the year, month, and day of the week, as well as which occurrence of that day of the week the specified TDateTime represents, use the DecodeDayOfWeekInMonth function.