WeekOfTheYear

Extract the week of the year (and optionally year) of a TDateTime indication.

Declaration

Source position: dateutil.inc line 177

  function WeekOfTheYear(const AValue: TDateTime) : Word;  Overload;
  function WeekOfTheYear(const AValue: TDateTime; out AYear: Word) : Word
                        ;  Overload;

Description

WeekOfTheYear extracts the week of the year from Avalue and returns it, and optionally returns the year as well. It returns the same value as WeekOf .

Remark

Note that weeks are numbered from 1 using the ISO 8601 standard, and the day of the week as well. This means that the year may not be the same as the year part of the date, since the week may start in the previous year as the first week of the year is the week with at least 4 days in it. !!!

See also

Name Description
DayOfTheYear Extracts the day of the year from a TDateTime value
HourOfTheYear Calculate the number of hours passed since the start of the year.
MilliSecondOfTheYear Calculate the number of milliseconds elapsed since the start of the year.
MinuteOfTheYear Calculate the number of minutes elapsed since the start of the year
MonthOfTheYear Extract the month of a TDateTime indication.
SecondOfTheYear Calculate the number of seconds elapsed since the start of the year.
WeekOf Extract week (of the year) from a given date.

Example

Program Example40;
{ This program demonstrates the WeekOfTheYear function }
Uses SysUtils,DateUtils;
Var
  N : TDateTime;
Begin
  N:=Now;
  Writeln('Month of the year       : ',MonthOfTheYear(N));
  Writeln('Week of the year        : ',WeekOfTheYear(N));
  Writeln('Day of the year         : ',DayOfTheYear(N));
  Writeln('Hour of the year        : ',HourOfTheYear(N));
  Writeln('Minute of the year      : ',MinuteOfTheYear(N));
  Writeln('Second of the year      : ',SecondOfTheYear(N));
  Writeln('MilliSecond of the year : ',
          MilliSecondOfTheYear(N));
End.