Help with wordpress custom query and advanced custom fields plugin

first of all sorry for my bad english. Let me explain what I`m trying to do:

I have a column inside a SQL table with a string using the following format: yy-mm-dd

Read More

The thing is, it doesn`t use a dateformat type.

So, I have my query, where I need to capture all fields with the following specification: value <= ‘{$thisyear}-{$thismonth}-{$last_day}’ any way that I can do that withoung having to change the field format? As long as the tables are generated by the plugin.

Any help will be really appreciated, thank you guys!

Related posts

Leave a Reply

1 comment

  1. $yesterday = array ( 
        'year' => date('y'), 
        'month' => date('m'), 
        'day' => date('d')-1 
    );
    
    $rows = $wpdb->query($wpdb->prepare(*emphasized text*
        "SELECT id, yymmdd 
        FROM plugin_data 
        WHERE yymmdd LIKE '%d-%d-%d", 
        $yesterday['year'], $yesterday['month'], $yesterday['day']
    ));
    
    foreach ( $rows as $r ) {
        $id_for_yesterday_rows[]= $r->id;
    }
    

    Now you have all ids or rows that were submitted yesterday in an array.