Board index » delphi » Date-Time-Query in MS-Access

Date-Time-Query in MS-Access

Hi,

I try to do a query from Delphi4 in an Access database. The querytext is

"SELECT * FROM DBT_Datum WHERE Datum < #01.01.90 13:31:00#"
In the database explorer I get no error and the expected result.
But in Delphi I always get an error. I guess my problem is simply
formatting - ie, getting something acceptable in my SQL command, but
I've tried several things now and all return errors.

Is there anyone how can help me?

regards Henning

 

Re:Date-Time-Query in MS-Access


I changed your WHERE clause and it works on my PC.

WHERE Datum < #01-01-90#

Christophe.

Henning Franke heeft geschreven in bericht <3A5DBC0E.70568...@gmx.de>...

Quote
>Hi,

>I try to do a query from Delphi4 in an Access database. The querytext is

>"SELECT * FROM DBT_Datum WHERE Datum < #01.01.90 13:31:00#"
>In the database explorer I get no error and the expected result.
>But in Delphi I always get an error. I guess my problem is simply
>formatting - ie, getting something acceptable in my SQL command, but
>I've tried several things now and all return errors.

>Is there anyone how can help me?

>regards Henning

Re:Date-Time-Query in MS-Access


Hi Christophe,

The query depends both on date and on time because it is a datetime field in
the table.

Henning

Re:Date-Time-Query in MS-Access


I didn't think that you could use international date formats when querying
through the BDE(DAO) but I could be wrong. Try using the DateValue function
instead which should convert the date.

SELECT * FROM DBT_Datum WHERE (Datum < DateValue("01.01.90")) or ((Datum =
DateValue("01.01.90")) and (Datum <#13:31:00#))

HTH
Woody

Quote
"Henning Franke" <Henning.Fra...@gmx.de> wrote in message

news:3A5DBC0E.70568AAA@gmx.de...
Quote
> Hi,

> I try to do a query from Delphi4 in an Access database. The querytext is

> "SELECT * FROM DBT_Datum WHERE Datum < #01.01.90 13:31:00#"
> In the database explorer I get no error and the expected result.
> But in Delphi I always get an error. I guess my problem is simply
> formatting - ie, getting something acceptable in my SQL command, but
> I've tried several things now and all return errors.

> Is there anyone how can help me?

> regards Henning

Re:Date-Time-Query in MS-Access


Quote
>I try to do a query from Delphi4 in an Access database. The querytext is

>"SELECT * FROM DBT_Datum WHERE Datum < #01.01.90 13:31:00#"
>In the database explorer I get no error and the expected result.
>But in Delphi I always get an error. I guess my problem is simply
>formatting - ie, getting something acceptable in my SQL command, but
>I've tried several things now and all return errors.

Try changing the colons to periods
SELECT * FROM DBT_Datum WHERE Datum < #01.01.90 13.31.00#
--
Brian Bushay (TeamB)
Bbus...@NMPLS.com

Other Threads