Board index » delphi » Local SQL e DateFields

Local SQL e DateFields

Hi friends.
I'm using: Delphi 2.0 / BDE 3.0 / Dbase files / Local SQL

I need to manipulate DateFields with Local SQL, but I'm having
problems.

I need to construct a SQL to retrieve records based on a Date fields,
like this:
obs: file is a .dbf file
       date1 and date2 are Date fields
       now is the current date

select * from File where date2 = "  /  /    "  and  date1 < now;

In runtime, a receive a 'Type mismatch' error.
How to write this  SQL sentence?

Thanks in advance.

Hrcules Russano
HRsft - "Simples, mas funciona"
S?o Gon?alo - RJ - Brasil

 

Re:Local SQL e DateFields


Hi,

Try this :

select * from File where date2 is null  and  date1 < now;

Voc est bem longe de mim.! ! !

Elio

--
Elio Medeiros
Rio de Janeiro - Brasil
e-mail <el...@hotmail.com>

Re:Local SQL e DateFields


Quote
>I need to construct a SQL to retrieve records based on a Date fields,
>like this:
>obs: file is a .dbf file
>       date1 and date2 are Date fields
>       now is the current date

>select * from File where date2 = "  /  /    "  and   date1 < now;

>In runtime, a receive a 'Type mismatch' error.
>How to write this  SQL sentence?

What do you expect
Quote
> date2 = "  /  /    "

to give you?  If you are looking for a field with no value use

Quote
>date1 < now;

You can not use now directly in a query.  So you have two choices
build the query dynamically

query1.sql.add (' and Date1 = '+quotedStr(StrToDate(now))') ;

or use a paramater in your query

query1.sql.add (' and Date1 = :N')
query1.parambyName('N').asDateTime := Now ;

date2 is Null

--
Brian Bushay (TeamB)
Bbus...@NMPLS.com

Re:Local SQL e DateFields


On Sun, 22 Nov 1998 01:22:54 GMT, hruss...@uol.com.br (Hercules

Quote
Russano) wrote:

I try: select * from file where date is null and date2 <
formatDateTime('mm/dd/yyyy',now) and
works very well.

Thanks for all.

(To Elio Medeiros: estamos prximos, e vamos buscar informa??es um
pouco longe. Fazer o qu?)

Quote
>Hi friends.
>I'm using: Delphi 2.0 / BDE 3.0 / Dbase files / Local SQL

>I need to manipulate DateFields with Local SQL, but I'm having
>problems.

>I need to construct a SQL to retrieve records based on a Date fields,
>like this:
>obs: file is a .dbf file
>       date1 and date2 are Date fields
>       now is the current date

>select * from File where date2 = "  /  /    "  and  date1 < now;

>In runtime, a receive a 'Type mismatch' error.
>How to write this  SQL sentence?

>Thanks in advance.

>Hrcules Russano
>HRsft - "Simples, mas funciona"
>S?o Gon?alo - RJ - Brasil

Hrcules Russano
HRsft - "Simples, mas funciona"
S?o Gon?alo - RJ - Brasil

Other Threads