How to compare date in MySQL query

Hi,

I have

 $date = date("Y-m-d"); 

How do I get date comparison in MySQL query that looks something like this:


SELECT expired_date
FROM subscription
WHERE expired_date > '$date'

Thanks

Hi there,

An easier/cleaner way to do this is as follows:

SELECT expired_date FROM subscription WHERE expired_date > CURRENT_TIMESTAMP;

HTH

What Pullo has said above would be better but if you need to convert a string to date in MySQL look at the STR_TO_DATE function.

pullo, using CURRENT_DATE instead of CURRENT_TIMESTAMP will more closely match the original requirements here

Oops. Right you are! :blush:
Thanks rudy.

Thanks,

I knew I can rely on your guys here. :slight_smile: