Hi
I have SQL Server 2012 (and D XE2) and a table with DateTime-Fields. If I access this field I get the following results:
in ManagementStudio the SQL SELECT CAST(myDate AS INT) returns0 (as expected)
in ManagementStudio the SQL SELECT myDate returns 1900-01-01 00:00:00.000
in Delphi with a TMsTable myTable.FieldByName('myDate').AsDateTime Returns 2 (why??)
I redevelop an old BDE-application, and in BDE "AsDateTime" was 0 and "AsString" 31.12.1899
Can you please give me some explanations why I get other values? Thanks, Peter
SQL Server and DateTime-Fields
-
AndreyZ
Re: SQL Server and DateTime-Fields
Hello,
In Delphi, the value 2 is the correct value for the date 1/1/1900. You can check this using the following code:For more information, please read the following article: http://docs.embarcadero.com/products/ra ... eTime.html
In Delphi, the value 2 is the correct value for the date 1/1/1900. You can check this using the following code:
Code: Select all
var
dt: double;
begin
dt := 2;
ShowMessage(DateTimeToStr(dt));
end;Re: SQL Server and DateTime-Fields
Thanks for your information. I see now the difference: in MS SQL the value 0 is 1.1.1900, in Delphi it's 30.12.1899.
-
AndreyZ
Re: SQL Server and DateTime-Fields
I am glad to help. If any other questions come up, please contact us.