System.DateUtils.NthDayOfWeek

From RAD Studio API Documentation
Jump to: navigation, search

Delphi

function NthDayOfWeek(const AValue: TDateTime): Word;

C++

extern DELPHI_PACKAGE System::Word __fastcall NthDayOfWeek(const System::TDateTime AValue);

Properties

Type Visibility Source Unit Parent
function public
System.DateUtils.pas
System.DateUtils.hpp
System.DateUtils System.DateUtils

Description

Returns the weekday of the specified TDateTime value.

NthDayOfWeek indicates the weekday within a month that 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.

See Also


Code Examples