Database & SQL

Moderators: None (Apply to moderate this forum)
Number of threads: 1174
Number of posts: 2221

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
SQL BETWEEN 'DATES' Posted by JamesFos on 19 Sept 2001 at 6:12 AM
I'm using Jet 4.0 and SQL to control an MS Access DB.

I have an sql statement.

SELECT Field1,
Field2,
Field3,
Expr1 AS ExprName1,
Expr2 AS ExprName2
FROM Tabel1,
Tabel2
WHERE Tabel1.PrimeKey = Tabel2.ForeignKey AND
Field2 BETWEEN '14/08/2001' AND '14/09/2001'

When i run it the server brings up an error "Invalid data type in condition statement". When i take out the part..

"Field2 BETWEEN '14/08/2001' AND '14/09/2001'"

.. it works fine and i have to restrict the date in the code (i'm using VB with SQL to access the data base).

does anyone know whats wrong? the code would be a lot simpler if the SQL statement could work.

TIA

Report
Re: SQL BETWEEN 'DATES' Posted by WEBMASTER on 25 Sept 2001 at 12:59 AM
Are you using the correct date format?

Also

try use

WHERE Field2=>'14/08/2001' and Field2 <= '14/09/2001'

Just and idea....



/WEBMASTER


Report
Re: SQL BETWEEN 'DATES' Posted by JamesFos on 25 Sept 2001 at 5:52 AM
I have all my dates set to DD/MM/YYYY and in the queries i use DD/MM/YYYY so what's wrong?

James

Report
Re: SQL BETWEEN 'DATES' Posted by WEBMASTER on 25 Sept 2001 at 6:04 AM
did you try to use

WHERE Field2=>'14/08/2001' and Field2 <= '14/09/2001'



/WEBMASTER


Report
Re: SQL BETWEEN 'DATES' Posted by JamesFos on 25 Sept 2001 at 11:51 AM
: did you try to use
:
: WHERE Field2=>'14/08/2001' and Field2 <= '14/09/2001'
:
:
:
: /WEBMASTER
:
:

Yes.

I really have no idea.

Is there a version of SQL which might not accept this? I'm using Jet 4.0.



Report
Re: SQL BETWEEN 'DATES' Posted by WEBMASTER on 25 Sept 2001 at 12:10 PM
Check the database helpfiles?

/WEBMASTER


Report
Re: SQL BETWEEN 'DATES' Posted by WEBMASTER on 25 Sept 2001 at 12:20 PM
Perhaps try reorder the date?

2001/08/14
2001-08-14



/WEBMASTER


Report
Re: SQL BETWEEN 'DATES' Posted by WEBMASTER on 25 Sept 2001 at 12:20 PM
Perhaps try reorder the date?

2001/08/14
2001-08-14



/WEBMASTER


Report
Re: SQL BETWEEN 'DATES' Posted by Cyt on 26 Sept 2001 at 7:07 AM
You must use DataValue('YOURDATE') to convert the date to the correct DATATIME format...

(I've just used 50 minutes searching all of my resources + the internet for that one - and I found it in the help four Visual C++ under "SQL, query criteria")

The code that I'm working on right now works now :

SELECT * FROM Schedules WHERE Start >= DateValue('04/10/2001') AND End <= DateValue('11/10/2001')






 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.