Sign in Join
FPDoc Onlineexperiment

RecodeDate function

In unit DateUtils

Replace date part of a TDateTime value with another date.

Declaration

pascal
function RecodeDate(const AValue: TDateTime; const AYear: Word; 
 const AMonth: Word; const ADay: Word): TDateTime

Arguments

AValue

Date/time to recode.

AYear

Year to replace in AValue.

AMonth

Month to replace in AValue.

ADay

Day to replace in AValue.

Function result

AValue with replaced date.

Description

RecodeDate replaces the date part of the timestamp AValue with the date specified in AYear, AMonth, ADay. All other parts (the time part) of the date/time stamp are left untouched.

Errors

If one of the AYear, AMonth, ADay values is not within a valid range then an EConvertError exception is raised.

See also

Example: ex94

pascal
Program Example94;

{ This program demonstrates the RecodeDate function }

Uses SysUtils,DateUtils;

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

Var
  S : AnsiString;

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

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