Quote
$query = "select 'Voting_Start_Date','Voting_End_Date' from 'j642_dcc_treasurer' where 'Entry_Date' like '".date(Y)."%'";
If Entry_Date is a
Date data type, why are you [implicitly] converting it into a String (of
unknown format) and then doing a wild-card comparison on that
String value, based on the user-entered "date" value,
also in
unknown format?
Rule #1 of
Date fields.
Date fields have
no format.
Only that which MySQL (and, possibly, the I.E.E.E.) keeps to itself and certainly
nothing like anything that you or I would call a "date".
...
"where Entry_Date = '" . formatTheDateSoThatMySqlCanMakeSenseOfIt( enteredDate ) . "' "
...
Why wouldn't MySQL be able to make sense of the entered "date"?
Because it has to interpret the "
character representation of a date" entered by the User into what it considers to be a
Date value.
What date does "01-02-03" represent?
Remember; when you're building an SQL statement, you're constructing a
String that
just happens to be meaningful to your DBMS.
Always be explicit with date formatting, so that there's zero risk of ambiguity.
Or use Parameterised Queries.
Regards, Phill W.