WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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!

share|improve this question
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? – helenhousandi Jun 19 '11 at 3:50
up vote 2 down vote accepted
$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.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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