[Lazarus] Conversion from TField.AsDateTime to string
Leonardo M. Ramé
l.rame at griensu.com
Fri Sep 9 22:59:49 CEST 2011
I'm working with a CGI that returns data as JSON. Then I read this data
from a GTK2 or Win32 client.
The JSON may have fields containing dates, that are populated from a
database using TSqlQuery, then converted to TDateTime using
Field.AsDateTime and added to a JSONObject using TJSonObject.Add(.., ..).
The result is something like this:
{
"apellido" : "BLANDINO",
"nombres" : "ALBERTO",
"fecha" : 40772.3926388889
}
On client side, instead of receiving 40772.3926388889 I can see this
while debugging:
' 4.07714066087963E+004'
I don't know, but maybe this is a GDB conversion issue.
To convert the JSON string to TDateTime, I use StrToFloat, then I show the result using:
FormatDateTime('YYYY-MM-DD', myDate);
On Linux I get: 2011-08-17 09:25:24
On Win32 I get: 34248-02-16 00:00:00
Why the difference?.
--
Leonardo M. Ramé
http://leonardorame.blogspot.com
More information about the Lazarus
mailing list