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!

  • Is this a WordPress or PHP/MySQL question? As in, is this a separate table and/or are you trying to use a WP query? Commented Jun 19, 2011 at 3:50

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.