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

# StartOfAWeek

Return a day of the week, given a year, week and day in the week.

## Declaration

Source position: dateutil.inc line 168

`function StartOfAWeek(`
`const AYear: Word;`
`const AWeekOfYear: Word;`
`const ADayOfWeek: Word`
`):TDateTime; function StartOfAWeek(`
`const AYear: Word;`
`const AWeekOfYear: Word`
`):TDateTime;`

## Arguments

`AYear` |  | Year
`AWeekOfYear` |  | Week in the year
`ADayOfWeek` |  | Day in the week (default 1)

## Function result

First day of the given week, in TDateTime format.

## Arguments

`AYear` |  | Year
`AWeekOfYear` |  | Week in the year

## Description

StartOfAWeek returns a TDateTime value with the date of the indicated day of the week indicated by the AYear, AWeek, ADayOfWeek values.

The default value for ADayOfWeek is 1.

## See also

StartOfTheWeek |  | Return the first day of the week, given a date.
EndOfTheWeek |  | Calculate a TDateTime value which represents the end of a week, given a date in that week.
EndOfAWeek |  | Return the last moment of day of the week, given a year and a week in the year.
StartOfAMonth |  | Return first date of month, given a year/month pair.
EndOfTheYear |  | Calculate a TDateTime value representing the last day of a year, given a date in that year.
EndOfAYear |  | Calculate a TDateTime value representing the last day of a year
EndOfTheMonth |  | Calculate a TDateTime value representing the last day of the month, given a day in that month.
EndOfAMonth |  | Calculate a TDateTime value representing the last day of the indicated month

## Example

    Program Example34;

    { This program demonstrates the StartOfAWeek function }

    Uses SysUtils,DateUtils;

    Const
      Fmt = '"First day of this week : "dd mmmm yyyy hh:nn:ss';
      Fmt2 = '"Second day of this week : "dd mmmm yyyy hh:nn:ss';

    Var
      Y,W : Word;

    Begin
      Y:=YearOf(Today);
      W:=WeekOf(Today);
      Writeln(FormatDateTime(Fmt,StartOfAWeek(Y,W)));
      Writeln(FormatDateTime(Fmt2,StartOfAWeek(Y,W,2)));
    End.

Documentation generated on: May 14 2021