Sign in Join
FPDoc Onlineexperiment

WeekOfTheMonth function

In unit DateUtils

Extract the week of the month (and optionally month and year) from a TDateTime value.

Declaration

pascal
function WeekOfTheMonth(const AValue: TDateTime): Word; overload

Arguments

AValue

TDateTime value of which to calculate the week, month and year.

Function result

Week of the month.

Description

WeekOfTheMonth extracts the week of the month from Avalue and returns it, and optionally returns the year and month as well (in AYear, AMonth respectively).

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 and month 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

Example: ex41

pascal
Program Example41;

{ This program demonstrates the WeekOfTheMonth function }

Uses SysUtils,DateUtils;

Var
  N : TDateTime;

Begin
  N:=Now;
  Writeln('Week of the Month        : ',WeekOfTheMonth(N));
  Writeln('Day of the Month         : ',DayOfTheMonth(N));
  Writeln('Hour of the Month        : ',HourOfTheMonth(N));
  Writeln('Minute of the Month      : ',MinuteOfTheMonth(N));
  Writeln('Second of the Month      : ',SecondOfTheMonth(N));
  Writeln('MilliSecond of the Month : ',
          MilliSecondOfTheMonth(N));
End.

An experiment, built from development snapshots. Not the official Free Pascal or Lazarus documentation.