Yeah Decode was what I was looking for, Still have a problem with it tho.
So my Saving routinge looks like this:
procedure TDatabase1.PRC_AbspeichernMesswert (Messung_val, CMD_Byte : integer); //CMD Bytes :1 für Modul,2 für Strommessung, 3 für PT100, 4 für Beschleunigung, 5 für Kraft
begin
SQLQuery1.Close;
SQLQuery1.SQL.Clear;
ProgressBar1.StepIt;
SQLQuery1.SQL.Text := 'INSERT INTO dbsensorreadings (Sensorwert, Einheit, Sensortyp, CommandByte, Zeit) values (:PH_val, :PH_unit, :PH_senstype,:PH_Cmd_Byte, :PH_Zeit)';
// other Params come here, took them out to make it simple
SQLQuery1.Params.ParamByName('PH_Zeit').AsDateTime := Now;
SQLQuery1.ExecSQL;
SQLTransaction1.CommitRetaining;
end;
This command will save the dates within my Database like this:
112|24|C°|Modultemperatur|15|2458337.56084822
113|24|C°|Modultemperatur|15|2458337.56144491
114|24|C°|Modultemperatur|15|2458337.56144676
115|24|C°|Modultemperatur|15|2458337.56144843
The last column is the date, it is obviously encoded. But if I run these values with the decode functions, it tells me the year is something around 8000. They should be 7th Aug 2018.
Using the 'now' function the way it is with decodedatetime does not cause any problems for me. The Problem is decoding a date that is within the Database.
The bigger picture I want to accomplish is give the user the ability to type in a gregorian date, then I want to encode that. And with the encoded Date I will be able to send a proper select Query towards the Database. But it seems like it's not saved the same way in the database as the 'now' command would save it if not used with the database.
So long story short, Using the 'now' within my application, that means decoding and encoding works fine now. The Problem is that the values within my database seem to be a different format.
I want to stress that it works with the charts and the dbgrid within my application tho, they show all the dates completely correct. I just seem to be failing at doing that conversion manually.
This is how I set up my table btw:
CREATE TABLE dbsensorreadings (id INTEGER PRIMARY KEY AUTOINCREMENT, Sensorwert NUMERIC, Einheit Text,Sensortyp Text,CommandByte TEXT, Zeit DATETIME);
And this is how I decode the time
procedure TDatabase1.Button1Click(Sender: TObject);
var
dt:Tdatetime;
YYYY, MM, DD, HH, Min, Sec, mSec :word;
begin
dt :=2458337.56084822;
DecodeDateTime(dt,YYYY,MM,DD,HH,Min,Sec,msec);
end;
Hope I didn't confuse you guys now
Best Regards