Reputation: 21
I need to put (IF) condition in my code to show only the datediff bigger than 0 but always happen error , anybody can help me please ?
SELECT DATEDIFF(`Date` ,CURDATE()) AS Date,`id` AS Dateid
FROM `election`
ORDER BY `Date` ASC
i need only Date bigger than 0
Upvotes: 2
Views: 69
Reputation: 4469
Not very pretty, but you can just recreate the date field in the where
clause to compare it:
SELECT DATEDIFF(`Date` ,CURDATE()) AS Date,`id` AS Dateid
FROM `election`
WHERE DATEDIFF(`Date` ,CURDATE()) > 0
ORDER BY `Date` ASC
Upvotes: 1