Watch, Follow, &
Connect with Us

Please visit our new home

Public Report
Report From: Delphi-BCB/Database/TField/TDateTimeField    [ Add a report in this area ]  
Report #:  134671   Status: Open
[FireDac] Calculating values of DateTime-fields lead to wrong values
Project:  Delphi Build #:  21.0.17707.5020
Version:    21.0 Submitted By:   Martin Stuhlmüller
Report Type:  Crash / Data loss / Total failure Date Reported:  11/4/2015 4:22:07 AM
Severity:    Serious / Highly visible problem Last Updated: 12/14/2015 6:22:19 AM
Platform:    All platforms Internal Tracking #:   72850
Resolution: None (Resolution Comments) Resolved in Build: : None
Duplicate of:  None
Voting and Rating
Overall Rating: No Ratings Yet
0.00 out of 5
Total Votes: None
An afterwards calculated value of a read out TimeStamp-Field is always wrong.

This example gives the right result (result: 42227,6111111111):
  Edit1.Text := FloatToStr(FDTable1['Zeitpunkt'])

This example gives a wrong result (result: 801685,611111111)
   Edit1.Text := FloatToStr(FDTable1['Zeitpunkt'] +0)

It doesn't matter if I add a zero or any other Integer-Value to the DateTime-Field. The result is always wrong.

I would expect that the result is equal to the other ways of calculating the result (see workarounds).
Maybe someone can tell me, what is going wrong in this case.

The database is not relevant. I tested it with MsSQL and the Advantage Database-System.

Also the way of getting the data is not relevant. A TFDQuery gets wrong results as well.
Steps to Reproduce:
var Dummy: Extended;
  Edit1.Text := FloatToStr(FDTable1['Zeitpunkt'] + 0);

  Edit2.Text := FloatToStr(FDTable1['Zeitpunkt']);

  Dummy := FDTable1['Zeitpunkt'] + 0;
  Edit3.Text := FloatToStr(Dummy);

Only Edit2 gives the right result.
Possibility 1:
Edit2.Text := FloatToStr(FDTable1.FieldByName('Zeitpunkt').AsFloat +0);

Possibility 2:
Var Dummy: Extended;
Dummy := FDTable1['Zeitpunkt']
Edit2.Text := FloatToStr(Dummy + 0);

Possibility 3:
Edit2.Text := FloatToStr(Extended(FDTable1['Zeitpunkt']) +0);


Server Response from: ETNACODE01