Description |
The EndOfAMonth function generates a TDateTime value set to the given Year and Month with the day set to the last of the month, and the time set to 1 milli-second before midnight.
The Year value must be between 0 and 9999.
The Month value must be between 1 (January) and 12 (December).
|
|
Notes |
Errors in the parameter values gives EConvertError.
|
|
Related commands |
EndOfADay |
|
Generate a TDateTime value set to the very end of a day |
|
|
|
Example code : Set the date to the last millisecond of February 2000, a leap month |
// Full Unit code. // ----------------------------------------------------------- // You must store this code in a unit called Unit1 with a form // called Form1 that has an OnCreate event called FormCreate. unit Unit1; interface uses DateUtils, // Unit containing the EndOfAMonth command SysUtils, Forms, Dialogs; type TForm1 = class(TForm) procedure FormCreate(Sender: TObject); end; var Form1: TForm1; implementation {$R *.dfm} // Include form definitions procedure TForm1.FormCreate(Sender: TObject); var
mydate : TDateTime;
begin
myDate := EndOfAMonth(2000, 2);
// Ensure that milli-seconds are shown
LongTimeFormat := 'hh:mm:ss.zzz';
ShowMessage('End of February 2000 = '+DateTimeToStr(myDate));
end; end.
|
Hide full unit code |
End of February 2000 = 29/02/2000 23:59:59.999
|
|