[Overview][Constants][Procedures and functions] |
Replace selected parts of a TDateTimevalue with other values
Source position: dateutil.inc line 345
function TryRecodeDateTime( |
const AValue: TDateTime; |
const AYear: Word; |
const AMonth: Word; |
const ADay: Word; |
const AHour: Word; |
const AMinute: Word; |
const ASecond: Word; |
const AMilliSecond: Word; |
var AResult: TDateTime |
):Boolean; |
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 |
AResult |
|
Recoded AValue. |
Trueif the recoding was succesful, Falseif not.
TryRecodeDateTimereplaces selected parts of the timestamp AValuewith the date/time values specified in AYear, AMonth, ADay, AHour, AMinute, ASecondand AMilliSecond. If any of these values equals the pre-defined constant RecodeLeaveFieldAsIs, then the corresponding part of the date/time stamp is left untouched.
The resulting date/time is returned in AValue.
The function returns Trueif the encoding was succesful. It returns Falseif one of the values AYear, AMonth, ADay, AHour, AMinute, ASecondAMilliSecondis not within a valid range.
|
Replace year part of a TDateTimevalue with another year. |
|
|
Replace month part of a TDateTimevalue with another month. |
|
|
Replace day part of a TDateTimevalue with another day. |
|
|
Replace hours part of a TDateTimevalue with another hour. |
|
|
Replace minutse part of a TDateTimevalue with another minute. |
|
|
Replace seconds part of a TDateTimevalue with another second. |
|
|
Replace milliseconds part of a TDateTimevalue with another millisecond. |
|
|
Replace date part of a TDateTimevalue with another date. |
|
|
Replace time part of a TDateTimevalue with another time. |
|
|
Replace selected parts of a TDateTimevalue with other values |
Program Example97; { This program demonstrates the TryRecodeDateTime function } Uses SysUtils,DateUtils; Const Fmt = 'dddd dd mmmm yyyy hh:nn:ss'; Var S : AnsiString; D : TDateTime ; Begin If TryRecodeDateTime(Now,2000,2,RecodeLeaveFieldAsIs,0,0,0,0,D) then begin S:=FormatDateTime(Fmt,D); Writeln('This moment in februari 2000 : ',S); end else Writeln('This moment did/does not exist in februari 2000'); End.