date parambyname

Discussion of open issues, suggestions and bugs regarding MyDAC (Data Access Components for MySQL) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
andrea.m86
Posts: 25
Joined: Thu 26 May 2011 10:36

date parambyname

Post by andrea.m86 » Fri 13 Apr 2012 06:53

Hi
I encountered this problem.
this kind of expression doesn't always work properly:

query1: TMyQuery;
datecomponent: (3rd party component);

query1.parambyname('start_date').value := datecomponent.date;

I solved using:

query1.parambyname('start_date').asdate := datecomponent.date;

but I have a lot of code already written to fix and in some other case i don't know in advance if the param that i will pass to my query is a date or something else, so i must use ".value"

AndreyZ

Post by AndreyZ » Fri 13 Apr 2012 11:22

Hello,

If you want to use the Value property, your third-party components (the datecomponent.date property) have to return dates as TDateTime. If they don't do it, please write about this problem to developers of your third-party components. Also, you can solve this problem in the way you have already found, by using the AsDate property instead of Value. Or you can explicitly cast datecomponent.date to TDateTime, for example:

Code: Select all

query1.parambyname('start_date').value := TDateTime(datecomponent.date);

andrea.m86
Posts: 25
Joined: Thu 26 May 2011 10:36

Post by andrea.m86 » Fri 13 Apr 2012 15:23

Ok. Thanks!
actually my components pass a TDate instead of a TDateTime.
I solved by modifying the unit of the component and it seems ok!

AndreyZ

Post by AndreyZ » Tue 17 Apr 2012 06:50

It's good to see that the problem was solved. If any other questions come up, please contact us.

Post Reply