One of the ways to do this is to not use DBWare components, and use the DataSet AfterScroll
and BeforePost
events to update your non-DBWare fields.
Given the DataHoraBanco
field you can do the following:
First create 2 fields without using DB components ( TEdit, TDateTimePicker, TMaskEdit
, etc)
dteDataForm
edtHoraForm
In your dataset in event AfterScroll
fill in:
procedure Form1.DataSetonAfterScroll(DataSet: TDataSet);
begin
dteDataForm.Date := Trunc(DataSet.FieldByName('DataHoraBanco').AsDateTime );
edtHoraForm.Text := FormatDateTime('hh:nn:ss', DataSet.FieldByName('DataHoraBanco').AsDateTime);
end;
And in event BeforePost
do:
procedure Form1.DataSetonAfterScroll(DataSet: TDataSet);
begin
DataSet.FieldByName('DataHoraBanco').AsDateTime := dteDataForm.Date +
StrToTime(edtHoraForm.Text);
end;
Remembering that the TDateTime type of delphi is a Double and so the Trunc function extracts the integer (date) and sum, the +
sign is used to add the decimal part equivalent to minutes and seconds.