I'm currently using the script below to report back the events start and end date over the period of one month, hence using 'first day of this month' and 'last day of this month'
I've no idea why but any events that start on the first of March have note been included, any help as to why would be great. Thanks
<?php
global $wpdb;
$result = $wpdb->get_results ( "
SELECT
$wpdb->posts.post_title,
substring_index(GROUP_CONCAT(meta_value order by str_to_date(meta_value,'%Y-%m-%d %H:%i:%s')), ',', 1) as start_date,
substring_index(GROUP_CONCAT(meta_value order by str_to_date(meta_value,'%Y-%m-%d %H:%i:%s')), ',', -1) as end_date
FROM $wpdb->posts INNER JOIN $wpdb->postmeta
ON $wpdb->posts.id = $wpdb->postmeta.post_id
WHERE $wpdb->postmeta.meta_key='_EventStartDate' OR $wpdb->postmeta.meta_key='_EventEndDate'
GROUP BY $wpdb->postmeta.post_id
ORDER BY $wpdb->postmeta.meta_value
" );
foreach ( $result as $page ) {
$date1 = new DateTime($page->start_date);
$date2 = new DateTime($page->end_date);
if (strtotime($page->start_date) >= strtotime('first day of this month') && strtotime($page->start_date) < strtotime('last day of this month')) {
echo '<h2><div class="date-title">';
echo $page->post_title;
echo '</div><div class="date-date">';
echo '<span class="orderby">Order by ' . $date1->format('d-m-y') . '</span><span class="deliveryby"> For Delivery ' . $date2->format('d-m-y').'</span><br/>';
echo '</div></h2>';
}
}
?>