RecodeTime

Replace time part of a TDateTime value with another time.

Declaration

Source position: dateutil.inc line 353

  function RecodeTime(const AValue: TDateTime; const AHour: Word; 
                     const AMinute: Word; const ASecond: Word; 
                     const AMilliSecond: Word) : TDateTime;

Description

RecodeTime replaces the time part of the timestamp AValue with the date specified in AHour, AMinute, ASecond and AMilliSecond. All other parts (the date part) of the date/time stamp are left untouched.

Errors

If one of the values AHour, AMinute, ASecondAMilliSecond is not within a valid range then an EConvertError exception is raised.

See also

Name Description
RecodeDate Replace date part of a TDateTime value with another date.
RecodeDateTime Replace selected parts of a TDateTime value with other values
RecodeDay Replace day part of a TDateTime value with another day.
RecodeHour Replace hours part of a TDateTime value with another hour.
RecodeMilliSecond Replace milliseconds part of a TDateTime value with another millisecond.
RecodeMinute Replace minutes part of a TDateTime value with another minute.
RecodeMonth Replace month part of a TDateTime value with another month.
RecodeSecond Replace seconds part of a TDateTime value with another second.
RecodeYear Replace year part of a TDateTime value with another year.

Example

Program Example95;
{ This program demonstrates the RecodeTime function }
Uses SysUtils,DateUtils;
Const
  Fmt = 'dddd dd mmmm yyyy hh:nn:ss';
Var
  S : AnsiString;
Begin
  S:=FormatDateTime(Fmt,RecodeTime(Now,8,0,0,0));
  Writeln('Today, 8 AM : ',S);
End.