WordPress.org

Ready to get started?Download WordPress

Forums

Meta_compare does not work in query for date comparison (2 posts)

  1. bhargavi
    Member
    Posted 4 years ago #

    I have a custom date field and am trying to pull events between two dates. meta_compare does not have a BETWEEN operator and if I use two meta_compares the first one is ignored.

    Please help.

    query_posts($query_string . "&showposts=-1&meta_key=Start%20Date&orderby=meta_value" . "&meta_key=Start%20Date&meta_compare=>=&meta_value=" . date('Y/m/d',$first_day) . "&meta_compare=<=&meta_value=" . date('Y/m/d',$last_day) . "&order=ASC");

    Thanks

  2. MichaelH
    Member
    Posted 4 years ago #

    As you've found, don't think you can do that. Might need to resort to something similar to the Examples here: http://codex.wordpress.org/wpdb#SELECT_a_Column

Topic Closed

This topic has been closed to new replies.

About this Topic