You are not logged in.
I need use a query to get data from database as TSQLTableJSON.
TSQLTableJSON of 2 fields as TCreateTime and TModTime (create e edit date of record);
How can I get TDateTime from these 2 fields?
Offline
I have try this:
TimeLogToDateTime(GetInt64(Table.Get(x, y)));
but with last versions of framework I get an error: "Invalid argument to time encode".
The some code in the past it's ok.
Any idea?
Offline
Why not use just use the function TSQLTable.GetAsDateTime() ?
If you get an error here, this may be because of wrong value in the field, i.e. not a true TTimeLog value.
Offline
I just have try TSQLTable.GetAsDateTime() but I get always "30/12/1899".
I have check on my database: all RecordCreated and RecordModified have 0 as value.
I don't have understand the error, I have a TSQLRecord class like this:
TSQLProjects = class(TSQLRecord)
private
fRecordCreated: TCreateTime;
fRecordModified: TModTime;
...
published
property RecordCreated: TCreateTime read fRecordCreated write fRecordCreated;
property RecordModified: TModTime read fRecordModified write fRecordModified;
...
end;
I think these fields (RecordCreated and RecordModified) are handle by framework when I create, add or update a record, right?
I don't edit them by code.
Any ideas?
Offline
Are you sure you are using the Add/Update CRUD methods of the framework?
If you use direct SQL, those fields won't be filled.
Those TCreateTime and TModTime are ORM-related methods.
Those fields are checked during regression tests, even within the performance tests, so I wonder why you get 0...
Offline
I will make some test.
I'm working on my old project and only today I have update it with last version of framework after many time. I hope is not change something on framework from my last software compile.
Offline
OK. I have try to open my database with your SynDB Explorer (in the past I have open it with a 3rd editor) and both RecordCreated and RecordModified are not 0.
These are some value:
135039350706
135123213736
Anyway I get "30/12/1899" when I use TSQLTable.GetAsDateTime().
Offline
OK I make some test with my DB.
1. I have use GetString to retrive text value of fields:
135131870949
135128992597
135115886182
2. I have only change GetString to GetAsDateTime and I get these:
135131870949 -> 30/12/1899
135128992597 -> 30/12/1899
135115886182 -> 30/12/1899
the fields have different value but the datatime is the same.
Offline
When I execute TimeLogToDateTime(135131870949) it returns 41578.477512, which is correct.
I'm not able to reproduce your problem.
Please check your code.
Are you sure the field is clearly identified as sftModTime or sftCreateTime in the TSQLTable?
You need to set it manually, via TSQLTable.SetFieldType('FieldName',sftModTime), otherwise it will not use conversion from TTimeLog value.
Offline