Wordpress WP_Query compare only Month part of meta_query key

admin

Administrator
Staff member
i have been trying to use wordpress wp_query method, but my case is specific.

I need to select all product of the current month so here is my code

Code:
$args = array(
    'numberposts' => -1,
    'post_type' => 'product',

    'meta_query' => array(
            'Relation' => 'AND',
    array(
            'key'     => 'wpcf-product_status',
            'value'   => 'valid',
            'compare' => '='
        ),
    array(
            'key'     => 'wpcf-product-start_date',
            'compare' => '=',

            'date_query' => array(
                array(
                        'month'      => date('m'),
                        'compare'   => '=',
                ),              
        ),
    ),
    ),
);
// get results
$the_query = new WP_Query( $args );

I can not get the exact result.
how is it possible to test only the date MONTH like it is done is SQL (
Code:
WHERE MONTH(wpcf-product-start_date) = MONTH(NOW())
)

any idea please?