I have a function which should return the future event date:
function get_upcoming_exercises( $limit = -1 ) {
$args = array(
'post_type' => 'px_event',
'posts_per_page' => $limit,
'post_status' => 'publish',
'meta_query' => array(
array(
'key' => '_px_event_date',
'value' => date('m-d-y'),
'compare' => '>=',
),
),
'orderby' => 'key',
'order' => 'DESC',
);
$query = new WP_Query( $args );
return $query;
}
the dates are stored like strings(m-d-y):
10-25-2012
01-03-2013
The function doesn't work fine, because, if I test, for example, with dates greater than 11-22-2012 it doesn't show 01-03-2013.
If I execute the comparison in mysql it fails too:
select * from wp_postmeta
where meta_key = '_px_event_date'
and meta_value >= '11-22-2012'
What am I doing wrong?