Posts

Showing posts with the label How to encode a datetime in delphi

How to encode a datetime in delphi

function EncodeDateTime ( const AYear : Word ; const AMonth : Word ; const ADay : Word ; const AHour : Word ; const AMinute : Word ; const ASecond : Word ; const AMilliSecond : Word ): TDateTime ; See this example uses DateUtils ; var myDateTime : TDateTime ; begin //Your Code myDateTime := EncodeDateTime ( 2009 , 11 , 28 , 14 , 23 , 12 , 000 ); //Your Code End ; Another option uses SysUtils ; var myDateTime : TDateTime ; begin //Your Code myDateTime := EncodeDate ( 2009 , 11 , 28 )+ EncodeTime ( 14 , 23 , 12 , 000 ); //Your Code end ; The second option works because the  TDatetime  It is stored as a Double ( TDateTime = type Double; ), with the date as the integral part (the  EncodeDate  function returns the integral), and time as fractional part. The date part of the TDateTime represents the number of days that have passed since 12/30/1899. a TDateTime can be any date through 31 Dec 9...