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

# DayOfTheWeek

Extracts the day of the week from a TDateTime value

## Declaration

Source position: dateutil.inc line 214

`function DayOfTheWeek(`
`const AValue: TDateTime`
`):Word;`

## Arguments

`AValue` |  | TDateTime to extract the day of the week from.

## Function result

Day of the week from AValue.

## Description

DayOfTheWeek returns the number of days that have passed since the start of the week till the moment indicated by AValue. This is a one-based number, i.e. the first day of the week will return 1.

## See also

DayOfTheYear |  | Extracts the day of the year from a TDateTime value
DayOfTheMonth |  | Extract the day (of month) part of a TDateTime value
HourOfTheWeek |  | Calculate the number of hours elapsed since the start of the week.
MinuteOfTheWeek |  | Calculate the number of minutes elapsed since the start of the week
SecondOfTheWeek |  | Calculate the number of seconds elapsed since the start of the week
MilliSecondOfTheWeek |  | Calculate the number of milliseconds elapsed since the start of the week

## Example

    Program Example42;

    { This program demonstrates the WeekOfTheMonth function }

    Uses SysUtils,DateUtils;

    Var
      N : TDateTime;

    Begin
      N:=Now;
      Writeln('Day of the Week         : ',DayOfTheWeek(N));
      Writeln('Hour of the Week        : ',HourOfTheWeek(N));
      Writeln('Minute of the Week      : ',MinuteOfTheWeek(N));
      Writeln('Second of the Week      : ',SecondOfTheWeek(N));
      Writeln('MilliSecond of the Week : ',
              MilliSecondOfTheWeek(N));
    End.