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

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!

1 Answer
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.

Tags:

Leave a Reply

Your email address will not be published. Required fields are marked *