I have a varchar field that hold a date as mm/dd/yyyy - I want a query that will only return records where the dates are in the future... how would i do this?
select .... where date(field) > date('UserInput')
field
but you shoudl really consider setting that fiedl to a date field
As rulian points out, if the column is holding data that references a date, why wouldn't you use a DATE column type?
If you converted it to a DATE column type, you could simply do:
SELECT col1, col2 FROM myTable WHERE date_col > CURDATE()
Why would this not work:
$tdate = date('m/d/Y'); $rquery = "SELECT * FROM db where date('rdate') > date('$tdate')";
rdate is in the same format as tdate
it will, but it's better practise to use date fields as they are optimized for that functionality, and you dont need to slow your query up by converting your fields to dates.
thanks - got the hint... changed the field and it works great...
Now you can index it if needs be...