Posted by Dave on 06/04/05 05:51
Alex (mincua@gmail.com) decided we needed to hear...
> You forgot to tell him that if he uses text inputs for dates he would
> have to use strtotime function or something like that because if you do
> a query like SELECT * FROM test WHERE date='Jan 1 2005' mysql would
> never return what you want ... or use postgresql :D.
> The mysql data format is this 2005-12-31 and the dates are compared as
> strings so it wouldn't convert 'Jan 1 2005' to '2005-01-01'
> automatically.
Exactly. Thats why I explained to the OP that it wasn't possible to
guess what was going on with the select without seeing what the
datatypes were in the table definition, and some of the sample inputs
from the form.
>
> I would tell him to use 3 selects and compose the date like
> '{$_POST['to_year']}-{$_POST['to_month']}-{$_POST['to_day']}' because
> even if he uses strtotime it wouldn't cover any date syntax.
I agree, thats a much better way than expecting users to type in a
date - and expecting them not to make mistakes ;)
--
Dave <dave@REMOVEbundook.com>
(Remove REMOVE for email address)
Navigation:
[Reply to this message]
|