diff --git a/inc/caldav-REPORT-calquery.php b/inc/caldav-REPORT-calquery.php index b411403f..d41a9e90 100644 --- a/inc/caldav-REPORT-calquery.php +++ b/inc/caldav-REPORT-calquery.php @@ -122,10 +122,10 @@ function SqlFilterFragment( $filter, $components, $property = null, $parameter = if ( isset($start) && isset($finish) ) { $sql .= sprintf( "AND ( (%s >= %s::timestamp with time zone AND %s <= %s::timestamp with time zone) ", $start_column, qpg($start), $finish_column, qpg($finish)); - $sql .= sprintf( "OR (calculate_later_timestamp(%s::timestamp with time zone,%s,rrule) >= %s::timestamp with time zone ", qpg($start), $start_column, qpg($start) ); - $sql .= sprintf( "AND calculate_later_timestamp(%s::timestamp with time zone,%s,rrule) >= %s::timestamp with time zone ", qpg($finish), $finish_column, qpg($finish) ); - $sql .= sprintf( "AND calculate_later_timestamp(%s::timestamp with time zone,%s,rrule) <= ", qpg($start), $start_column ); - $sql .= sprintf( " calculate_later_timestamp(%s::timestamp with time zone,%s,rrule) ) ", qpg($finish), $finish_column ); + $sql .= sprintf( "OR (calculate_later_timestamp(%s::timestamp with time zone,%s,rrule) >= %s::timestamp with time zone ", qpg($start), $finish_column, qpg($start) ); + $sql .= sprintf( "AND calculate_later_timestamp(%s::timestamp with time zone,%s,rrule) <= %s::timestamp with time zone ", qpg($start), $start_column, qpg($finish) ); + $sql .= sprintf( "AND calculate_later_timestamp(%s::timestamp with time zone,%s,rrule) <= ", qpg($start), $finish_column ); + $sql .= sprintf( " calculate_later_timestamp(%s::timestamp with time zone,%s,rrule) ) ", qpg($start), $start_column ); $sql .= sprintf( "OR event_has_exceptions(caldav_data.caldav_data) ) " ); } else if ( isset($start) ) {