Reputation: 656
I have a PHP query that I only want to select if the date is 2014 in the table:
$result=mysqli_query($linkID, "SELECT * FROM table WHERE date(Y) = '2014'";
I'm trying to call "date(Y)" with the correct expression as that is obviously incorrect.
Upvotes: 0
Views: 544
Reputation: 4081
Use this:
$result=mysqli_query($linkID, "SELECT * FROM table WHERE YEAR(datetime_field) = 2014");
Upvotes: 0
Reputation: 15827
the query should be
SELECT * FROM table WHERE YEAR(the_date_field) = 2014
the_date_field
is the field containing the date of course
Upvotes: 1