Sign in Join
FPDoc Onlineexperiment

RecodeDay function

In unit DateUtils

Replace day part of a TDateTime value with another day.

Declaration

pascal
function RecodeDay(const AValue: TDateTime; const ADay: Word)
: TDateTime

Arguments

AValue

Date to recode.

ADay

Day to replace in AValue.

Function result

AValue with replaced day.

Description

RecodeDay replaces the Day part of the timestamp AValue with ADay. All other parts of the date/time stamp are left untouched.

Errors

If the ADay value is not within a valid range (1 till the number of days in the month) then an EConvertError exception is raised.

See also

Example: ex89

pascal
Program Example89;

{ This program demonstrates the RecodeDay function }

Uses SysUtils,DateUtils;

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

Var
  S : AnsiString;

Begin
  S:=FormatDateTime(Fmt,RecodeDay(Now,1));
  Writeln('This moment on the first of the month : ',S);
End.

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