[Overview][Constants][Procedures and functions][Index] Reference for unit 'DateUtils' (#rtl)

WeekOfTheYear

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

Declaration

Source position: dateutil.inc line 190

function WeekOfTheYear(

  const AValue: TDateTime

):Word; overload;

function WeekOfTheYear(

  const AValue: TDateTime;

  out AYear: Word

):Word; overload;

Arguments

AValue

  

Date from which to extract week.

Function result

Week of the year in which Avalue falls.

Arguments

AValue

  

Date from which to extract week.

AYear

  

Year part of AValue

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

WeekOf

  

Extract week (of the year) from a given date.

MonthOfTheYear

  

Extract the month of a TDateTime indication.

DayOfTheYear

  

Extracts the day of the year from a TDateTime value

HourOfTheYear

  

Calculate the number of hours passed since the start of the year.

MinuteOfTheYear

  

Calculate the number of minutes elapsed since the start of the year

SecondOfTheYear

  

Calculate the number of seconds elapsed since the start of the year.

MilliSecondOfTheYear

  

Calculate the number of milliseconds elapsed since the start of the year.

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.

Documentation generated on: May 14 2021