Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can you tell me why my SQL query doesn't work?

Status
Not open for further replies.

martindavey

Programmer
Jan 2, 2000
122
GB
Can you tell me why this query returns nothing...

Select * From "myTable"
Where Date >= #26/5/01# and Date <= #1/6/01#
Order By Date

The table 'myTable' contains the following row...

Date
26/5/01

NB. UK Date Format dd/mm/yy
1. I have the following at the top of my page:
<% Session.LCID = 2057 ' English Locale %>
2. I have the date set to British on my PC
 
I had similar trouble pulling dates from Oracle tables. I had to reformat the date. Here was my SQL fix

Select * From &quot;myTable&quot;
Where Date >= '26-May-2001' and Date <= '1-Jun-2001'
Order By Date
;

Also try adding the semicolon if missing.

IF MSAcess try &quot;Where Date > #25/05/01#&quot; to see if it returns results.
Eric

If you create something idiot proof,
Nature will create a better idiot.
 
Thanks Eric,
I think the problem was that Access wants the SQL in US format regardless of the regional settings.
 
This is the query string that works in my database..

SELECT * FROM bbb WHERE (lastinq > '06/01/2001' AND lastinq < '07/01/2001'))&quot;

What I'm seeing is that my dates are surrounded in single quotes, and yours have none.. You might try that..

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top