 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Jorge Ferreira Guest
|
Posted: Mon Jan 05, 2004 5:26 pm Post subject: SQL Query - BETWEEN command |
|
|
Hello experts,
I've got a query that i would like to run but there's something wrong with
it.
The query has the following sql string: ('SELECT * FROM CAL WHERE DATE_INI
BETWEEN "DATEVALUE1" AND "DATEVALUE2" ');
It always returns an error. Probably there's someting wrong with the code.
Can someone please help?
Thanks
Jorge
|
|
| Back to top |
|
 |
Tony J Hopkinson Guest
|
Posted: Mon Jan 05, 2004 6:39 pm Post subject: Re: SQL Query - BETWEEN command |
|
|
On Mon, 5 Jan 2004 17:26:58 -0000, "Jorge Ferreira"
<jorge.ferreira (AT) lycos (DOT) co.uk> wrote:
| Quote: | Hello experts,
I've got a query that i would like to run but there's something wrong with
it.
The query has the following sql string: ('SELECT * FROM CAL WHERE DATE_INI
BETWEEN "DATEVALUE1" AND "DATEVALUE2" ');
It always returns an error. Probably there's someting wrong with the code.
Can someone please help?
Thanks
Jorge
What Database ? |
Syntax Error ?
What format are the dates in. ?
Does Where date_ini >= "Datavalue1" and date_ini <= "Datevalue 2" ?
Are Datevalue1 & 2 being replaced by actual dates correctly ?
|
|
| Back to top |
|
 |
Andrew Pailthorpe Guest
|
Posted: Mon Jan 05, 2004 7:08 pm Post subject: Re: SQL Query - BETWEEN command |
|
|
"Jorge Ferreira" <jorge.ferreira (AT) lycos (DOT) co.uk> wrote
| Quote: | Hello experts,
I've got a query that i would like to run but there's something wrong with
it.
The query has the following sql string: ('SELECT * FROM CAL WHERE DATE_INI
BETWEEN "DATEVALUE1" AND "DATEVALUE2" ');
It always returns an error. Probably there's someting wrong with the code.
Can someone please help?
Thanks
Jorge
What error do you get ? |
|
|
| Back to top |
|
 |
Bill Todd (TeamB) Guest
|
Posted: Tue Jan 06, 2004 12:27 am Post subject: Re: SQL Query - BETWEEN command |
|
|
"DATEVALUE1" and "DATEVALUE2" are string literals, not dates. Is what
you posted the actual SQL you are executing? What database are you
using? What is the datatype of the DATE_INI column?
--
Bill (TeamB)
(TeamB cannot respond to questions received via email)
|
|
| Back to top |
|
 |
Jorge Ferreira Guest
|
Posted: Tue Jan 06, 2004 4:08 pm Post subject: Re: SQL Query - BETWEEN command |
|
|
First of all, thank you for your answer.
The DATE_INI column is a Date Field.
Yes, the DATEVALUE1 and DATEVALUE2 are string literals.
Before the query i transform the values to string through DateToStr function
for they are Date in the form (DatePickers).
Do you have any idea?
Thanx again,
Jorge Ferreira
"Bill Todd (TeamB)" <no (AT) no (DOT) com> escreveu na mensagem
news:h40kvvcfhovmkkc4d5a4m066aguei3gbu3 (AT) 4ax (DOT) com...
| Quote: | "DATEVALUE1" and "DATEVALUE2" are string literals, not dates. Is what
you posted the actual SQL you are executing? What database are you
using? What is the datatype of the DATE_INI column?
--
Bill (TeamB)
(TeamB cannot respond to questions received via email)
|
|
|
| Back to top |
|
 |
Bill Todd (TeamB) Guest
|
Posted: Tue Jan 06, 2004 6:36 pm Post subject: Re: SQL Query - BETWEEN command |
|
|
On Tue, 6 Jan 2004 16:08:22 -0000, "Jorge Ferreira"
<jorge.ferreira (AT) lycos (DOT) co.uk> wrote:
| Quote: | Do you have any idea?
|
Not without seeing the actual SQL that is being executed. Set a
breakpoint on the statement that executes the SQL then get the value
of the SQL property and post it here so we can see the actual SQL that
is generating the error.
--
Bill (TeamB)
(TeamB cannot respond to questions received via email)
|
|
| Back to top |
|
 |
Jorge Ferreira Guest
|
Posted: Thu Jan 08, 2004 2:23 pm Post subject: Re: SQL Query - BETWEEN command |
|
|
The SQL Query is this:
The Field "Nome" is a String Alpha Field.
The Field "Data_nascimento" is a Date one.
'SELECT Nome, Data_nascimento from Cal WHERE Data_nascimento Between
12-01-1975 AND 31-12-1975' and with this command (is i run it in DataBase
Desktop),
I get the following error : "Type mismatch in expression" witch is the same
i get in Delphi, naturally.
If i change the SQL Statement to:
'SELECT Nome, Data_nascimento from Cal WHERE Data_nascimento Between
(12-01-1975 AND 31-12-1975)',
I get the error: "Invalid use of keyword"
I tried almost anything that i remenbered and i'm still stuked in this.
Can you tell me anything?
Jorge Ferreira
"Bill Todd (TeamB)" <no (AT) no (DOT) com> escreveu na mensagem
news:ruvlvv8479h8o251e14jquj521ttdfbpgu (AT) 4ax (DOT) com...
| Quote: | On Tue, 6 Jan 2004 16:08:22 -0000, "Jorge Ferreira"
[email]jorge.ferreira (AT) lycos (DOT) co.uk[/email]> wrote:
Do you have any idea?
Not without seeing the actual SQL that is being executed. Set a
breakpoint on the statement that executes the SQL then get the value
of the SQL property and post it here so we can see the actual SQL that
is generating the error.
--
Bill (TeamB)
(TeamB cannot respond to questions received via email)
|
|
|
| Back to top |
|
 |
Andrew Pailthorpe Guest
|
Posted: Thu Jan 08, 2004 2:47 pm Post subject: Re: SQL Query - BETWEEN command |
|
|
Try using the US date format for your dates
ie 'SELECT Nome, Data_nascimento from Cal WHERE Data_nascimento Between
("01/12/1975" AND "12/31/1975")',
MM/DD/YYYY
"Jorge Ferreira" <jorge.ferreira (AT) lycos (DOT) co.uk> wrote
| Quote: | The SQL Query is this:
The Field "Nome" is a String Alpha Field.
The Field "Data_nascimento" is a Date one.
'SELECT Nome, Data_nascimento from Cal WHERE Data_nascimento Between
12-01-1975 AND 31-12-1975' and with this command (is i run it in DataBase
Desktop),
I get the following error : "Type mismatch in expression" witch is the
same
i get in Delphi, naturally.
If i change the SQL Statement to:
'SELECT Nome, Data_nascimento from Cal WHERE Data_nascimento Between
(12-01-1975 AND 31-12-1975)',
I get the error: "Invalid use of keyword"
I tried almost anything that i remenbered and i'm still stuked in this.
Can you tell me anything?
Jorge Ferreira
"Bill Todd (TeamB)" <no (AT) no (DOT) com> escreveu na mensagem
news:ruvlvv8479h8o251e14jquj521ttdfbpgu (AT) 4ax (DOT) com...
On Tue, 6 Jan 2004 16:08:22 -0000, "Jorge Ferreira"
[email]jorge.ferreira (AT) lycos (DOT) co.uk[/email]> wrote:
Do you have any idea?
Not without seeing the actual SQL that is being executed. Set a
breakpoint on the statement that executes the SQL then get the value
of the SQL property and post it here so we can see the actual SQL that
is generating the error.
--
Bill (TeamB)
(TeamB cannot respond to questions received via email)
|
|
|
| Back to top |
|
 |
Jorge Ferreira Guest
|
Posted: Thu Jan 08, 2004 5:48 pm Post subject: Re: SQL Query - BETWEEN command |
|
|
Error: "Invalid use of Keyword".
Is anything in there that may be a keyword? I don't see it but ...
I'm almost giving up paradox ... this command in access is easy as hell.
Thank you for your reply anyway.
"Andrew Pailthorpe" <yuppski (AT) hotmail (DOT) com> escreveu na mensagem
news:3ffd6d63$1 (AT) newsgroups (DOT) borland.com...
| Quote: | Try using the US date format for your dates
ie 'SELECT Nome, Data_nascimento from Cal WHERE Data_nascimento Between
("01/12/1975" AND "12/31/1975")',
MM/DD/YYYY
"Jorge Ferreira" <jorge.ferreira (AT) lycos (DOT) co.uk> wrote in message
news:3ffd676a (AT) newsgroups (DOT) borland.com...
The SQL Query is this:
The Field "Nome" is a String Alpha Field.
The Field "Data_nascimento" is a Date one.
'SELECT Nome, Data_nascimento from Cal WHERE Data_nascimento Between
12-01-1975 AND 31-12-1975' and with this command (is i run it in
DataBase
Desktop),
I get the following error : "Type mismatch in expression" witch is the
same
i get in Delphi, naturally.
If i change the SQL Statement to:
'SELECT Nome, Data_nascimento from Cal WHERE Data_nascimento Between
(12-01-1975 AND 31-12-1975)',
I get the error: "Invalid use of keyword"
I tried almost anything that i remenbered and i'm still stuked in this.
Can you tell me anything?
Jorge Ferreira
"Bill Todd (TeamB)" <no (AT) no (DOT) com> escreveu na mensagem
news:ruvlvv8479h8o251e14jquj521ttdfbpgu (AT) 4ax (DOT) com...
On Tue, 6 Jan 2004 16:08:22 -0000, "Jorge Ferreira"
[email]jorge.ferreira (AT) lycos (DOT) co.uk[/email]> wrote:
Do you have any idea?
Not without seeing the actual SQL that is being executed. Set a
breakpoint on the statement that executes the SQL then get the value
of the SQL property and post it here so we can see the actual SQL that
is generating the error.
--
Bill (TeamB)
(TeamB cannot respond to questions received via email)
|
|
|
| Back to top |
|
 |
Andrew Pailthorpe Guest
|
Posted: Thu Jan 08, 2004 6:15 pm Post subject: Re: SQL Query - BETWEEN command |
|
|
The brackets are not required.
SELECT Nome, Data_nascimento from Cal WHERE Data_nascimento Between
"01/12/1975" AND "12/31/1975"
"Jorge Ferreira" <jorge.ferreira (AT) lycos (DOT) co.uk> wrote
| Quote: | Error: "Invalid use of Keyword".
Is anything in there that may be a keyword? I don't see it but ...
I'm almost giving up paradox ... this command in access is easy as hell.
Thank you for your reply anyway.
"Andrew Pailthorpe" <yuppski (AT) hotmail (DOT) com> escreveu na mensagem
news:3ffd6d63$1 (AT) newsgroups (DOT) borland.com...
Try using the US date format for your dates
ie 'SELECT Nome, Data_nascimento from Cal WHERE Data_nascimento Between
("01/12/1975" AND "12/31/1975")',
MM/DD/YYYY
"Jorge Ferreira" <jorge.ferreira (AT) lycos (DOT) co.uk> wrote in message
news:3ffd676a (AT) newsgroups (DOT) borland.com...
The SQL Query is this:
The Field "Nome" is a String Alpha Field.
The Field "Data_nascimento" is a Date one.
'SELECT Nome, Data_nascimento from Cal WHERE Data_nascimento Between
12-01-1975 AND 31-12-1975' and with this command (is i run it in
DataBase
Desktop),
I get the following error : "Type mismatch in expression" witch is the
same
i get in Delphi, naturally.
If i change the SQL Statement to:
'SELECT Nome, Data_nascimento from Cal WHERE Data_nascimento Between
(12-01-1975 AND 31-12-1975)',
I get the error: "Invalid use of keyword"
I tried almost anything that i remenbered and i'm still stuked in
this.
Can you tell me anything?
Jorge Ferreira
"Bill Todd (TeamB)" <no (AT) no (DOT) com> escreveu na mensagem
news:ruvlvv8479h8o251e14jquj521ttdfbpgu (AT) 4ax (DOT) com...
On Tue, 6 Jan 2004 16:08:22 -0000, "Jorge Ferreira"
[email]jorge.ferreira (AT) lycos (DOT) co.uk[/email]> wrote:
Do you have any idea?
Not without seeing the actual SQL that is being executed. Set a
breakpoint on the statement that executes the SQL then get the value
of the SQL property and post it here so we can see the actual SQL
that
is generating the error.
--
Bill (TeamB)
(TeamB cannot respond to questions received via email)
|
|
|
| Back to top |
|
 |
Bill Todd (TeamB) Guest
|
Posted: Thu Jan 08, 2004 8:07 pm Post subject: Re: SQL Query - BETWEEN command |
|
|
SELECT Nome, Data_nascimento from Cal WHERE Data_nascimento Between
"01/12/1975" AND "12/31/1975"
Should work. If it does not, give us the complete text of the error
message.
--
Bill (TeamB)
(TeamB cannot respond to questions received via email)
|
|
| Back to top |
|
 |
Wayne Niddery [TeamB] Guest
|
Posted: Fri Jan 09, 2004 4:52 am Post subject: Re: SQL Query - BETWEEN command |
|
|
Andrew Pailthorpe wrote:
| Quote: | Try using the US date format for your dates
ie 'SELECT Nome, Data_nascimento from Cal WHERE Data_nascimento
Between ("01/12/1975" AND "12/31/1975")',
MM/DD/YYYY
|
Note that standard SQL requires *single* quotes around literal values,
double quotes denote identifiers (table or field names).
..
--
Wayne Niddery - Logic Fundamentals, Inc. (www.logicfundamentals.com)
RADBooks: http://www.logicfundamentals.com/RADBooks.html
"It is error alone which needs the support of government. Truth can
stand by itself." - Thomas Jefferson
|
|
| Back to top |
|
 |
Jorge Ferreira Guest
|
Posted: Mon Jan 12, 2004 3:12 pm Post subject: Re: SQL Query - BETWEEN command |
|
|
Hello my friends
I've tried everything that you guys told me and it didn't worked.
If i could, i'de post here the table so you could see what's wrong...
Thank you anyway,
Jorge
"Wayne Niddery [TeamB]" <wniddery (AT) chaffaci (DOT) on.ca> escreveu na mensagem
news:3ffe38ed (AT) newsgroups (DOT) borland.com...
| Quote: | Andrew Pailthorpe wrote:
Try using the US date format for your dates
ie 'SELECT Nome, Data_nascimento from Cal WHERE Data_nascimento
Between ("01/12/1975" AND "12/31/1975")',
MM/DD/YYYY
Note that standard SQL requires *single* quotes around literal values,
double quotes denote identifiers (table or field names).
.
--
Wayne Niddery - Logic Fundamentals, Inc. (www.logicfundamentals.com)
RADBooks: http://www.logicfundamentals.com/RADBooks.html
"It is error alone which needs the support of government. Truth can
stand by itself." - Thomas Jefferson
|
|
|
| Back to top |
|
 |
Jorge Ferreira Guest
|
Posted: Mon Jan 12, 2004 3:22 pm Post subject: Re: SQL Query - BETWEEN command |
|
|
I tried everything that you told me but unfortunatelly it didn't worked.
If i could, i'd post the Table in here so you could see, what's going on.
I tried the Between command with and without Brackets "()", with and without
double and single quotes, and the errors are always the same:
"Invalid use of keyword" - If i use the command without braquets
"Invalid use of Keyword" - If i use the command with braquets
Best Regards,
Jorge Ferreira
"Bill Todd (TeamB)" <no (AT) no (DOT) com> escreveu na mensagem
news:43ervvk8slpat819it476s0ed47kob4pl6 (AT) 4ax (DOT) com...
| Quote: | SELECT Nome, Data_nascimento from Cal WHERE Data_nascimento Between
"01/12/1975" AND "12/31/1975"
Should work. If it does not, give us the complete text of the error
message.
--
Bill (TeamB)
(TeamB cannot respond to questions received via email)
|
|
|
| Back to top |
|
 |
Wayne Niddery [TeamB] Guest
|
Posted: Mon Jan 12, 2004 5:56 pm Post subject: Re: SQL Query - BETWEEN command |
|
|
Jorge Ferreira wrote:
| Quote: | I tried everything that you told me but unfortunatelly it didn't
worked.
If i could, i'd post the Table in here so you could see, what's going
on.
I tried the Between command with and without Brackets "()", with and
without double and single quotes, and the errors are always the same:
"Invalid use of keyword" - If i use the command without braquets
"Invalid use of Keyword" - If i use the command with braquets
|
I've reviewed this thread and it seems you never told us what database you
are using. This may have saved some time (Bill asked you for this at the
beginning). My guess is that database does not understand "BETWEEN". Change
your query to:
... Data_nascimento >= '12-01-1975' AND Data_nascimento <= '31-12-1975'
--
Wayne Niddery - Logic Fundamentals, Inc. (www.logicfundamentals.com)
RADBooks: http://www.logicfundamentals.com/RADBooks.html
"It is error alone which needs the support of government. Truth can
stand by itself." - Thomas Jefferson
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|