AsDate / TDate Field

Discussion of open issues, suggestions and bugs regarding SDAC (SQL Server Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
OlliWW
Posts: 25
Joined: Mon 25 Mar 2013 17:03

AsDate / TDate Field

Post by OlliWW » Fri 28 Jul 2017 21:47

Hello,

In Microsoft SQL Server you can declare DateTime and Date Fields.

When using SDAC you can set a Parameter like this way for a date-Field:

Code: Select all

qryExec.Params.ParamByName('StartDate').AsDate
But when you select values from a MS DB with:

Code: Select all

qrySelect.FieldByName('StartDate').As........
you only have "AsDateTime", which results in a cast error, when selecting a Date-Field.
In Delphi you also have "TDate". So it would be nice to have a "AsDate" Funktion also when you are using FieldByName. Is there any way to achieve this?

azyk
Devart Team
Posts: 1119
Joined: Fri 11 Apr 2014 11:47
Location: Alpha Centauri A

Re: AsDate / TDate Field

Post by azyk » Mon 31 Jul 2017 07:37

The cause of the specified error is not SDAC, but the behavior specificity of the standard TField class. To avoid it, please refer to the following article in Embarcadero documentation: http://docwiki.embarcadero.com/Librarie ... AsDateTime

Post Reply