Description |
The DecodeTime procedure extracts hour, minute, second and milli-second values from a given SourceDateTime TDateTime type value.
It stores the values in the output variables : Hour, Min, Sec and MSec.
|
|
Related commands |
DecodeDate |
|
Extracts the year, month, day values from a TDateTime var. |
DecodeDateTime |
|
Breaks a TDateTime variable into its date/time parts |
EncodeDate |
|
Build a TDateTime value from year, month and day values |
EncodeDateTime |
|
Build a TDateTime value from day and time values |
EncodeTime |
|
Build a TDateTime value from hour, min, sec and msec values |
RecodeDate |
|
Change only the date part of a TDateTime variable |
RecodeTime |
|
Change only the time part of a TDateTime variable |
ReplaceDate |
|
Change only the date part of a TDateTime variable |
ReplaceTime |
|
Change only the time part of a TDateTime variable |
|
|
|
Example code : Add 5 minutes to a time and then extract the new time values |
var
myDate : TDateTime;
myHour, myMin, mySec, myMilli : Word;
begin // Set up the myDate variable to have a December 2000 value
myDate := StrToDateTime('29/12/2000 12:45:12.34');
// Now add 5 minutes to this value
myDate := IncMinute(myDate, 5);
// And let us see what we get
DecodeTime(myDate, myHour, myMin, mySec, myMilli);
ShowMessage('Time now = '+TimeToStr(myDate));
ShowMessage('Hour = '+IntToStr(myHour));
ShowMessage('Minute = '+IntToStr(myMin));
ShowMessage('Second = '+IntToStr(mySec));
ShowMessage('MilliSec = '+IntToStr(myMilli));
end;
|
Show full unit code |
Time now = 12:50:12
Hour = 12
Minute = 50
Second = 12
MilliSec = 34
|
|