EncodeDate (Delphi)

From RAD Studio Code Examples
Jump to: navigation, search

Description

This example uses three edit controls, a label, and a button on a form. When the button is clicked, the day, month, and year specified in the edit controls is stored in a TDateTime object. Then the TDateTime object is converted to an AnsiString that is displayed in the label.

Code

procedure TForm1.Button1Click(Sender: TObject);
var
  MyDate: TDateTime;
begin
  MyDate := SysUtils.EncodeDate(StrToInt(Edit1.Text), StrToInt(Edit2.Text), StrToInt(Edit3.Text));
  Label1.Caption := DateToStr(MyDate);
end;

Uses