TbufDataSet, formating a date field lazarus / 16-Databases ---------------------------------------------------------------------- cpalx · 2021-07-17 18:02 Hello, how could ia format a field date in TbufDataSet ---------------------------------------------------------------------- lucamar · 2021-07-17 21:59 As with any other dataset: add a field to FieldDefs with the proper type (ftDate, ftTime, ftTimeStamp, ...). You can set it or read it back with Field.AsDateTime. ---------------------------------------------------------------------- cpalx · 2021-07-18 17:35 @lucamar, i wanted to say: formatdate like 'dd/mm/yyyy' not field type. ---------------------------------------------------------------------- wp · 2021-07-18 18:03 Use the 'DisplayFormat' property of the field. You must cast the field to TDateField, TDateTimeField, or TTimefield to have access to this property. The following code works with a TBufDataset, TDataSource and a TDBGrid on a form (linked in the usual way): Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TForm1.FormCreate(Sender: TObject);var  i: Integer;  F: TField;begin  BufDataset1.FileName := 'data.db';  if not FileExists(BufDataset1.FileName) then  begin    BufDataset1.FieldDefs.Add('date', ftDate);    BufDataset1.CreateDataset;    BufDataset1.Open;    for i := 0 to 100 do      BufDataset1.AppendRecord([Random(365) + EncodeDate(2020, 1, 1)]);  end;  BufDataset1.Open;   F := BufDataset1.FieldByName('date');  if F is TDateField then    TDateField(F).DisplayFormat := 'yyyy-mm-dd';end;