RAD Studio VCL Reference
ContentsIndex
PreviousUpNext
DateUtils.WeekOf Function

Returns the week of the year represented by a TDateTime value.

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

Call WeekOf to obtain the week of the year represented by a specified TDateTime value. WeekOf returns a value between 1 and 53.  

WeekOf uses the ISO 8601 standard to define the week of the year. That is, a week is defined as running from Monday through Sunday, and the first week of the year is defined as the one the first calendar week of the year is the one that includes the first Thursday of the year (the first week that includes four or more days in the year). This means that if the first calendar day of the year is a Friday, Saturday, or Sunday, then for the first three, two, or one days of the calendar year, WeekOf returns the last week of the previous year. Similarly, if the last calendar day of the year is a Monday, Tuesday, or Wednesday, then for the last one, two, or three days of the calendar year, WeekOf returns 1 (the first week of the next calendar year).

Note: WeekOf returns the same value as the WeekOfTheYear function.
 

 

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!