Hey I have set up a db and i want to make a query between 2 dates, the dates format is for example today (21-12-2005) I used this SELECT * FROM cust WHERE '23-01-2005'> sold_date AND '20-01-2006' <= sold_date; but it only picks up the first 2 numbers, and compares that. my data consists of 21-12-05 and 22-12-05 using that brings everything up, ok but change the first date from 23-01-2005 to 20-01-2005 and nothing comes up 21-12-05 comes after 20-01-05 doesn't it????
Date formats are usually database dependent. Mysql likes to use: 2005-12-31 while Oracle might use: '21-Mar-05'. Make sure you use the right format for your database or use a function to convert the date to something your database likes.
When we are making queries using dates we have to be careful. We cant use single quoataion for this. Use this query, hope it will solve your problem SELECT * FROM cust WHERE '23-01-2005'> sold_date AND '20-01-2006' <= sold_date; SELECT * FROM cust WHERE sold_date between #23-01-2005# AND #20-01-2006#