Delphi Examples: DbiTimeStampDecode

<< Click to Display Table of Contents >>

Navigation:  »No topics above this level«

Delphi Examples: DbiTimeStampDecode

Return to chapter overview

Decode a TimeStamp variable into a string including all information

This example uses the following input:

 fDbiTimeStampDecode(TS, Buffer);

 

The function is:

function fDbiTimeStampDecode(timestampTS: TimeStamp): string;

var

  DateVar: dbiDATE;

  TimeVar: TIME;

  hour, min, millsec, Month, Day: Word;

  Year: SmallInt;

begin  

 SetLength(Result, 100);

 Check(DbiTimeStampDecode(timestampTS, DateVar, TimeVar));

 Check(DbiTimeDecode(TimeVar, hour, min, millsec));

 Check(DbiDateDecode(DateVar, Month, Day, Year));

if (hour > 12) then

   Result := Format('Time: %d:%d:%d PM, Date: %d/%d/%d',

     [hour - 12, min, millsec div 1000, Month, Day, Year])

else

   Result := Format('Time: %d:%d:%d AM, Date: %d/%d/%d',

     [hour, min, millsec div 1000, Month, Day, Year]);

 SetLength(Result, StrLen(PChar(Result)));

end;