RAD Studio VCL Reference
ContentsIndex
PreviousUpNext
DateUtils.NthDayOfWeek Function

Returns which occurrence of its weekday a specified TDateTime value represents.

Pascal
function NthDayOfWeek(const AValue: TDateTime): Word;
C++
Word NthDayOfWeek(const TDateTime AValue);

DateUtils

NthDayOfWeek indicates which occurrence of a weekday within a month the date and time specified by AValue represents. For example, if AValue represents the 2nd 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 4 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.
 

 

Copyright(C) 2008 CodeGear(TM). All Rights Reserved.
What do you think about this topic? Send feedback!