Forum Replies Created

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter mrmclovin

    (@mrmclovin)

    Thank you. I managed to get it to work with your code with a slight modification. Here’s my final code which is working.

    add_filter( 'em_events_build_sql_conditions', 'my_em_scope_conditions',1,2);
    	function my_em_scope_conditions($conditions, $args){
    	    if( !empty($args['scope']) && $args['scope']=='today-upcoming' ){
    	        $start_date = date('Y-m-d',current_time('timestamp'));
    	        $end_date = date('Y-m-d',current_time('timestamp'));
              $start_time = date('H:i',current_time('timestamp'));
              $end_time = '23:59';
    
    	        $conditions['scope'] = "((event_start_date BETWEEN CAST('$start_date' AS DATE) AND CAST('$end_date' AS DATE)) OR (event_end_date BETWEEN CAST('$end_date' AS DATE) AND CAST('$start_date' AS DATE))) AND ((event_start_time BETWEEN CAST('$start_time' AS TIME) AND CAST('$end_time' AS TIME)) OR (event_end_time BETWEEN CAST('$start_time' AS TIME) AND CAST('$end_time' AS TIME)))";
    
          }
    	    return $conditions;
    }

    Thread Starter mrmclovin

    (@mrmclovin)

    Hi,

    Thats what I did but it doesnt work. That’s why I posted my code here. I changed the SQL to
    (event_start_date BETWEEN CAST('$start_date' AS DATETIME) AND CAST('$end_date' AS DATETIME)) OR (event_end_date BETWEEN CAST('$end_date' AS DATETIME) AND CAST('$start_date' AS DATETIME)

    Can u see any errors there?

Viewing 2 replies - 1 through 2 (of 2 total)