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

TryEncodeDayOfWeekInMonth

Encode a year, month, week, day of week triplet to a TDateTime value

Declaration

Source position: dateutil.inc line 379

function TryEncodeDayOfWeekInMonth(

  const AYear: Word;

  const AMonth: Word;

  const ANthDayOfWeek: Word;

  const ADayOfWeek: Word;

  out AValue: TDateTime

):Boolean;

Arguments

AYear

  

Year

AMonth

  

Month in year

ANthDayOfWeek

  

Day of week occurrence

ADayOfWeek

  

Day of week

AValue

  

Resulting TDateTime value

Function result

True if the encoding was succesful, False if not.

Description

EncodeDayOfWeekInMonth encodes AYear, AMonth, ADayOfweek and ANthDayOfweek to a valid date stamp and returns the result in AValue.

ANthDayOfweekis the N-th time that this weekday occurs in the month, e.g. the third saturday of the month.

The function returns True if the encoding was succesful, False if any of the values is not in range.

See also

NthDayOfWeek

  

Calculate which occurrence of weekday in the month a given day represents

EncodeDateMonthWeek

  

Encodes a year, month, week of month and day of week to a DateTime value

#rtl.sysutils.DayOfWeek

  

Returns the day of the week.

DecodeDayOfWeekInMonth

  

Decode a DateTime value in year, month, day of week parts

EncodeDayOfWeekInMonth

  

Encodes a year, month, week, day of week specification to a TDateTime value

Example

Program Example105;

{ This program demonstrates the DecodeDayOfWeekInMonth function }

Uses SysUtils,DateUtils;

Var
  Y,M,NDoW,DoW : Word;
  D : TDateTime;
Begin
  DecodeDayOfWeekInMonth(Date,Y,M,NDoW,DoW);
  If TryEncodeDayOfWeekInMonth(Y,M,NDoW,DoW,D) then
    begin
    Write(DateToStr(D),' is the ',NDow,'-th ');
    Writeln(formatdateTime('dddd',D),' of the month.');
    end
  else
    Writeln('Invalid year/month/NthDayOfweek combination');
End.

Documentation generated on: Nov 16 2015