Date format in database

Posted in Databases

Sometimes it is necessary to change a date format of date field, when you show data from your database. You may use DisplayFormat property of TDateField type.

procedure TForm1.FormCreate(Sender: TObject);
begin
  with table1 do
  begin
    TDateField(FieldByName('Date1')).DisplayFormat:='dd*mm*yyyy';
    TDateField(FieldByName('Date2')).DisplayFormat:='ddmmyyyy';
    Active:=True;
  end;
end;