Page 1 of 1

select * from db where DATE = '2002-07-06 ...

Posted: Tue Aug 19, 2003 10:40 am
by coldarchon
how can I make a query with dates? I have an old Access file with the coloumns Date and Time, and I want to use the Between clause. But I even can´t get a query if I chose a specific date or time. The Date data look like yyyy-mm-dd 00:00:00 and the Time data look like 1899 etc.

I tried wildcards, date with time, just date, date with points, date as a variable, defining date as DATE in SQL, cascading SQL, and whatsoever.

Anyone?

Re: select * from db where DATE = '2002-07-06 ...

Posted: Tue Aug 19, 2003 2:28 pm
by Max.
coldarchon wrote:how can I make a query with dates? I have an old Access file with the coloumns Date and Time, and I want to use the Between clause. But I even can´t get a query if I chose a specific date or time. The Date data look like yyyy-mm-dd 00:00:00 and the Time data look like 1899 etc.

I tried wildcards, date with time, just date, date with points, date as a variable, defining date as DATE in SQL, cascading SQL, and whatsoever.

Anyone?
You have to use dates like #08/19/2003# (with the leading and trailing #) in Access, if I remember right.

Posted: Tue Aug 19, 2003 3:19 pm
by coldarchon
nope, doesn´t work for me. But the "Like" option works.

Select * From db Where Date Like '06.07.2002'

No Between ...

Posted: Tue Aug 19, 2003 4:00 pm
by Max.
coldarchon wrote:nope, doesn´t work for me. But the "Like" option works.

Select * From db Where Date Like '06.07.2002'

No Between ...
By using "LIKE '..." you are treating the column as if it was text.

Sorry, if I insist - I probably didn't quite catch you - but given a table "dates" that looks like

Code: Select all

id;datefield
0;30.12.2004 12:00:12
1;22.06.2012 14:00:01
2;08.08.1972 08:10:01
3;19.01.2002 07:03:00
an example query would be

Code: Select all

SELECT datefield FROM dates WHERE datefield>#1/1/1975# AND datefield<#1/1/2006#;
and return 2 rows of data:

Code: Select all

30.12.2004 12:00:12
19.01.2002 07:03:00
If this doesn't work, the column of the Access DB probably isn't formatted as Date/Time for whatever reason!?

And sorry for picking such lousy dates... :P

Posted: Thu Aug 28, 2003 7:44 pm
by coldarchon
hey, thanks for the help, I used the "Like"-option, it was too confusing. The date was like dd.mm.yyyy , the ODBC returns it like yyyy-mm-dd when I make a request like #mm/dd/yyyy# .

But now I´m stuck on creating an output into an *.xls sheet. How can I use the cell C3 (3, 3)?