views:

791

answers:

3

I'm trying to SELECT based on a date in OpenOffice Base:

SELECT *
  FROM OrderTbl
  WHERE OrdDate BETWEEN #1/1/2007# AND #1/31/2007#

I've tried a number of variations, but nothing is working. What is the correct syntax?

+1  A: 

This should work:

SELECT * 
FROM OrderTbl
WHERE OrdDate BETWEEN '2007-01-01' AND '2007-01-31'
David Walker
Thanks much, it works.
FarmBoy
A: 

use below Query SELECT * FROM OrderTbl WHERE OrdDate BETWEEN cast(convert(varchar,'1/1/2007',101) as datetime) AND cast((varchar,'1/31/2007',101) as datetime)

KuldipMCA
A: 

How I could do if I want to the user give me values for my range? Because this code doesn't work: SELECT * FROM ORDER_TABLE WHERE ORDER_DATE BETWEEN ? AND ? with this code works only ask me the first value, never ask me for the second.

Someone could you help me? please!

Paulo Ricardo
@Paulo, you need to ask a new question. This is a place to provide an answer to the question above. If you choose to open a new question, make sure to specify what database you are using, etc.
FarmBoy