I made some tests with the cli. I think the problem is also somehow at SQLite level.
The table is as the one described before. I inserted some records using REAL numbers.
sqlite> select strftime('%Y-%m-%d %H:%M:%f', datetimeField) from ExampleTable;
2022-04-22 10:30:34.000
2022-04-22 10:30:36.000
2022-04-22 10:30:39.000
-340-07-08 16:48:00.000
-312-04-22 16:48:00.000
-340-07-08 16:48:00.000
-258-11-22 16:48:00.000
0157-10-18 16:48:00.000
2895-09-14 16:48:00.000
sqlite> select * from ExampleTable;
1|2022-04-22 10:30:34
2|2022-04-22 10:30:36
3|2022-04-22 10:30:39
3|478694.2
3|578694.2
3|5758694.2
3|478694.2
3|778694.2
3|1778694.2
3|2778694.2
The result of the max operation in the cli is:
sqlite> select max(datetimeField) from ExampleTable;
2022-04-22 10:30:39
sqlite> select max(julianday(datetimeField)) from ExampleTable;
2778694.2
sqlite> select strftime('%Y-%m-%d %H:%M:%f', max(julianday(datetimeField))) from ExampleTable;
2895-09-14 16:48:00.000
So the problem is (also) in SQLite, I guess it's due to the fact that SQLite does not have an explicit datatype.
I will do as suggested by ZVoni, even if this will make the program not database independent (postgres does not have a julianday() function. I see no other solution now.