| |
| How can I determine the week number of a given day in the year? |
 |
How can I determine the week number of a given day in the year?
This is a highly debated subject, as the first week of the year may be considered to be before or after Jan. The following function provides a starting point for WeekOfYear calculations.
Example:
function WeekOfYear(ADate : TDateTime) : word;
var
day : word;
month : word;
year : word;
FirstOfYear : TDateTime;
begin
DecodeDate(ADate, year, month, day);
FirstOfYear := EncodeDate(year, , );
Result := Trunc(ADate - FirstOfYear) div 7 + ;
end;
procedure TForm .Button Click(Sender: TObject);
begin
ShowMessage(IntToStr(WeekOfYear(Date)));
end;
|
|
| Hits/month |
2,500,000+ |
Downloads (Since May 2000) |
7,393,709 |
| Total Files |
6,023 |
| Forum msgs |
7,670 |
| Articles/FAQs |
70+/900+ |
Top Selling Software at Amazon
|