Matt Ryan
Matt Ryan

Reputation: 3

Editing datetime fields in MySQL using Delphi and firedac

I am using Delphi 10.1 and Firedac components to connect to a MySQL database. Using live bindings or the VCL data aware components I can edit the data in the MySQL tables except for dates (e.g. invoice date). I understand there is a type difference between the Delphi TDateTime and MySQL DateTime in ISO format but I can't work out how or where to undertake a conversion? Any assistance greatly appreciated.

Many thanks

Matt

Upvotes: 0

Views: 855

Answers (1)

Uwe Raabe
Uwe Raabe

Reputation: 47819

You can add a data type mapping for the TFDConnection mapping dtTimeStamp into dtDateTime. Something like:

with FDConnection1.FormatOptions.MapRules.Add do begin
  SourceDataType := dtTimeStamp;
  TargetDataType := dtDateTime;
end;

Upvotes: 1

Related Questions