Board index » delphi » Format parameter in fields TDateTime.

Format parameter in fields TDateTime.

Hi,

   I have a problem when I write um statement SQL into a TQuery. This
statement SQL have a condition which compare um field TDateTime with a
parameter.
   The problem is that I cant found a format to write directly the
condition into statement SQL.

It is like this:
select
   Tombamento, DataTombo
from
  "TSA03_Tombamento"
where
   DataTombo = ??????????? format

OBS:   In the IBM SQL\DS I could write the condition like:
...
where
   DataTombo = '1998-03-30'

with the type of Field DataTombo DATE.

Due the nature of my problem, I cant to pass parameters through TParam.

Thanks to all

Excuse-me my poor English.

 

Re:Format parameter in fields TDateTime.


Quote
>Due the nature of my problem, I cant to pass parameters through TParam.

Why not?  If you can build the Query you should be able to give it a parameter.
Something like this should work:

        myQuery.SQL.Add('select Tombamento, DataTombo') ;
        myQuery.SQL.Add('from TSA03_Tombamento') ;
        myQuery.SQL.Add('where DataTombo = :theDate) ;
        myQuery.ParamByName['theDate'].Value := someDateVar

--
Clayton Neff
Software Project Leader
The Personal Marketing Company, Inc.
11843 West 83rd Terrace
Lenexa, KS  66214
(913)492-0322
clay...@tpmco.com

Re:Format parameter in fields TDateTime.


Quote
Clayton Neff wrote:
> >Due the nature of my problem, I cant to pass parameters through TParam.
> Why not?  If you can build the Query you should be able to give it a parameter.
> Something like this should work:

>         myQuery.SQL.Add('select Tombamento, DataTombo') ;
>         myQuery.SQL.Add('from TSA03_Tombamento') ;
>         myQuery.SQL.Add('where DataTombo = :theDate) ;
>         myQuery.ParamByName['theDate'].Value := someDateVar

> --

    Yes, You is correct. I already dont have much experience in Delphis
components.

    But, already is necessary add one line in your example:
        ...
        myQuery.SQL.Add('where DataTombo = :theDate) ;
        myQuery.ParamByName('theDate').DataType := ftDateTime;
        myQuery.ParamByName('theDate').Value := someDateVar;

   Thanks for its help.

        Eustakio.

Other Threads