DelphiBasics
EncodeDate
Function
Build a TDateTime value from year, month and day values SysUtils unit
 function EncodeDate ( const Year, Month, Day : Word ) : TDateTime;
Description
The EncodeDate function generates a TDateTime return value from the passed Year, Month and Day values.
 
The permitted parameter values are :
 
Year  = 2000..9999
Month  = 1..12
Day  = 1..31 (depending on month/year)

 
If you exceed these values, an EConvertError is raised.
Notes
The time value for the TDateTime is always set to 00:00:00.00
Related commands
DecodeDate Extracts the year, month, day values from a TDateTime var.
DecodeDateTime Breaks a TDateTime variable into its date/time parts
DecodeTime Break a TDateTime value into individual time values
EncodeDateTime Build a TDateTime value from day and time values
EncodeTime Build a TDateTime value from hour, min, sec and msec values
 Download this web site as a Windows program.
 
Example code : Assign a date to a TDateTime variable
var
  myDate : TDateTime;

begin
  // Set my date variable using the EncodeDate function
  myDate := EncodeDate(2000, 02, 29);

  LongTimeFormat := 'hh:mm:ss.zzz';  // Ensure that MSecs are shown

  ShowMessage('Date set to '+DateToStr(myDate));
  ShowMessage('Time set to '+TimeToStr(myDate));
end;
Show full unit code
   Date set to 29/02/2000
   Time set to 00:00:00.000
 
 
Delphi Programming Neil Moffatt 2002 - 2013. All rights reserved.  |  Contact the author  |  Home Page