Unit 'DateUtils' Package
[Overview][Constants][Classes][Procedures and functions][Index] [#rtl]

RecodeYear

Replace year part of a TDateTime value with another year.

Declaration

Source position: dateutil.inc line 367

function RecodeYear(

  const AValue: TDateTime;

  const AYear: Word

):TDateTime;

Arguments

AValue

  

Date to recode.

AYear

  

Year to replace in AValue.

Function result

AValue with replaced year.

Description

RecodeYear replaces the year part of the timestamp AValue with AYear. All other parts of the date/time stamp are left untouched.

Errors

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

See also

RecodeMonth

  

Replace month part of a TDateTime value with another month.

RecodeDay

  

Replace day part of a TDateTime value with another day.

RecodeHour

  

Replace hours part of a TDateTime value with another hour.

RecodeMinute

  

Replace minutes part of a TDateTime value with another minute.

RecodeSecond

  

Replace seconds part of a TDateTime value with another second.

RecodeMilliSecond

  

Replace milliseconds part of a TDateTime value with another millisecond.

RecodeDate

  

Replace date part of a TDateTime value with another date.

RecodeTime

  

Replace time part of a TDateTime value with another time.

RecodeDateTime

  

Replace selected parts of a TDateTime value with other values.

Example

Program Example87;

{ This program demonstrates the RecodeYear function }

Uses SysUtils,DateUtils;

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

Var
  S : AnsiString;

Begin
  S:=FormatDateTime(Fmt,RecodeYear(Now,1999));
  Writeln('This moment in 1999 : ',S);
End.

Documentation generated on: Dec 23 2024