One of the ways to do this is to not use Dbware components, and use Dataset events AfterScroll
and BeforePost
to update your fields that are not Dbware.
Considering the field DataHoraBanco
you can do the following:
Create 2 fields without using DB components (TEdit, TDateTimePicker, TMaskEdit
, etc.)
dteDataForm
edtHoraForm
On your dataset at the 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 at the 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 therefore the Trunc function extracts the whole part (date) and in the sum, the signal is used +
to add up the decimal part equivalent to minutes and seconds.