I want to search SQL database using PHP and look for meta_value. The meta_value contains data like this:
So what I want to do is make it search for the UpdatedDate and see if it is between 2000-01-01 to (todays date - 5 days).
This is what I did so far, which is not working.
global $wpdb; // Global object database variable $updatedDate = ; //set how many days odds will show until.. currently set to -5 days. $endDatefind = (new \DateTime('now'))->modify("-5 day")->format('Y-m-d'); // creating datetime object //finds all dates from 2000 to 5 days before todays date $findquery = $wpdb->get_results ( " SELECT * FROM `wp_postmeta` WHERE`meta_key` = 'Odd' AND STR_TO_DATE(meta_value, '%Y-%m-%d') >= '2000-01-01' AND STR_TO_DATE(meta_value, '%Y-%m-%d') =< '$endDatefind' ");
Any ideas why its not finding any data? I tried to do a dummy data by changing one row with an 'UpdatedDate' of last 2 weeks, but it is not showing. Please help thanks.