I'm trying to pull records from a MySQL database using a sql query - to pull records where the "exp_date" field is greater than or equal to today. How do I do this?
$query = "SELECT v_title,link_id,v_descr,hw_added,hw_region_id,approved,user_approved,exp_date FROM ec3_ad WHERE hw_feat=1 AND approved=1 AND user_approved=1 AND hw_region_id=103 AND exp_date>=strftime('%d %b %Y %H:%M:%S') ORDER BY hw_added DESC LIMIT 20";
... but this is obviously not working because I don't know how to add today's date/time dynamically to the query.
Any help would be great!
[/quote]
Last edited by lkalisky on Tue Sep 18, 2007 9:53 am, edited 1 time in total.
SELECT v_title,link_id,v_descr,hw_added,hw_region_id,approved,user_approved,exp_date FROM ec3_ad WHERE hw_feat=1 AND approved=1 AND user_approved=1 AND hw_region_id=103 AND exp_date>=NOW() ORDER BY hw_added DESC LIMIT 20
Would work in postgres. It uses the SQL "now()" to get the current information based on the current SQL server time. Not sure if it is the same in MySQL. If not I'm sure someone will let you know.