Board index » delphi » AsDate/AsDateTime help needed _desperately_

AsDate/AsDateTime help needed _desperately_

Hi all,

I have a TQuery with a SELECT-statement. This query needs some
parameters.

I have a Var called DateFrom of type TDateTime. I try this to pass to
a parameter of the TQuery with the following statement:

Query.ParamByName('DateFr').AsDateTime := DateFrom

Now when running the query I am getting no results back. After having
added watches and examining them I see the following:

DateFrom has something like the value 35065. This is correct since
TDateTime is a longint. (The date is 1-1-96)

Examining  Query.ParamByName('DateFr') reveals as something like:

($8A7150,'1-1-96'+ a lot of garbage,'DateFr',ftDateTime, False,True,
ptUnknown)

In other words AsDateTime goes haywire when converting. It's adding
garbage after the correct date. And what is even stranger, when using
AsDateTime in a TTable all goes well.
Table.FieldByName('DateFr').AsDateTime gives the correct date !

Any help or workaround needed _desperately_

MArk

 

Re:AsDate/AsDateTime help needed _desperately_


Quote
Mark Smits wrote:

> Hi all,

> I have a TQuery with a SELECT-statement. This query needs some
> parameters.

> I have a Var called DateFrom of type TDateTime. I try this to pass to
> a parameter of the TQuery with the following statement:

> Query.ParamByName('DateFr').AsDateTime := DateFrom

> Now when running the query I am getting no results back. After having
> added watches and examining them I see the following:

It might not be the best solution but I am using AsString and it works
just great...

Sylvain.

Other Threads