RecodeDateTime function
Replace selected parts of a
TDateTime value with other values.
Declaration
function RecodeDateTime(const AValue: TDateTime; const AYear: Word;
const AMonth: Word; const ADay: Word;
const AHour: Word; const AMinute: Word;
const ASecond: Word; const AMilliSecond: Word)
: TDateTimeArguments
AValue | Date/time to recode. |
AYear | New value for year part. |
AMonth | New value for month part. |
ADay | New value for day part. |
AHour | New value for hour part. |
AMinute | New value for minute part. |
ASecond | New value for second part. |
AMilliSecond | New value for millisecond part. |
Function result
AValue with replaced parts.Description
RecodeDateTime replaces selected parts of the timestamp
AValue
with the date/time values specified in
AYear,
AMonth,
ADay,
AHour,
AMinute,
ASecond and
AMilliSecond. If any of these values
equals the predefined constant
RecodeLeaveFieldAsIs, then
the corresponding part of the date/time stamp is left untouched.Errors
If one of the values
AYear,
AMonth,
ADay,
AHour,
AMinute,
ASecond
AMilliSecond is not within a valid range (
RecodeLeaveFieldAsIs excepted)
then an
EConvertError exception is raised.
See also
- RecodeYear
- RecodeMonth
- RecodeDay
- RecodeHour
- RecodeMinute
- RecodeSecond
- RecodeMilliSecond
- RecodeDate
- RecodeTime
- TryRecodeDateTime
Example: ex96
Program Example96;
{ This program demonstrates the RecodeDateTime function }
Uses SysUtils,DateUtils;
Const
Fmt = 'dddd dd mmmm yyyy hh:nn:ss';
Var
S : AnsiString;
D : TDateTime ;
Begin
D:=Now;
D:=RecodeDateTime(D,2000,2,RecodeLeaveFieldAsIs,0,0,0,0);
S:=FormatDateTime(Fmt,D);
Writeln('This moment in februari 2000 : ',S);
End.An experiment, built from development snapshots. Not the official Free Pascal or Lazarus documentation.
