Sign in Join
FPDoc Onlineexperiment

RecodeMonth function

In unit DateUtils

Replace month part of a TDateTime value with another month.

Declaration

pascal
function RecodeMonth(const AValue: TDateTime; const AMonth: Word)
: TDateTime

Arguments

AValue

Date to recode.

AMonth

Month to replace in AValue.

Function result

AValue with replaced month.

Description

RecodeMonth replaces the Month part of the timestamp AValue with AMonth. All other parts of the date/time stamp are left untouched.

Errors

If the AMonth value is not within a valid range (1..12) then an EConvertError exception is raised.

See also

Example: ex88

pascal
Program Example88;

{ This program demonstrates the RecodeMonth function }

Uses SysUtils,DateUtils;

Const
  Fmt = 'dddd dd mmmm yyyy hh:nn:ss';

Var
  S : AnsiString;

Begin
  S:=FormatDateTime(Fmt,RecodeMonth(Now,5));
  Writeln('This moment in May : ',S);
End.

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