protected function queryDay(string $strDateStart, string $strDateEnd)
    {
        $strQuery = $this->querySelectFrom($strDateStart)
            . $this->queryJoin()
            . $this->queryWhereNotExpired();

        // Happening today
        $strQuery .= ' AND (';

            // Original date matches
            $strQuery .= ' sked_events.starts_at BETWEEN :date_start AND :date_end';

            // Or it's already started and...
            $strQuery .= ' OR (sked_events.starts_at <= :date_start AND (';

                // Daily
                $strQuery .= ' (
                    sked_events.interval = "1"
                    AND (
                        DATEDIFF(
                            :date_start_NOTIME,
                            DATE_FORMAT(sked_events.starts_at, "%Y-%m-%d")
                        )/sked_events.frequency
                    ) % 1 =0
                )';

                // Day of week matches for weekly events
                $strQuery .= ' OR (
                    sked_events.interval = "7"
                    AND sked_events.' . date('D', strtotime($strDateStart)) . ' = 1
                    AND (
                        DATEDIFF(
                            :date_start_NOTIME,
                            DATE_FORMAT(sked_events.starts_at, "%Y-%m-%d")
                        )/7
                    ) % sked_events.frequency = 0
                )';

                // Monthly by day of week
                // Calculate how many months since first session, see if it's an exact match for today
                $strQuery .= ' OR (
                    sked_events.interval = "Monthly"
                    AND sked_events.' . date('D', strtotime($strDateStart)) . ' = 1
                    AND TIMESTAMPADD(
                        MONTH,
                        ROUND(DATEDIFF(:date_start, DATE_FORMAT(sked_events.starts_at, "%Y-%m-%d"))/30),
                        sked_events.starts_at
                    ) BETWEEN :date_start AND :date_end
                )';

                // Monthly by date
                $strQuery .= ' OR (
                    sked_events.interval = "Monthly"
                    AND sked_events.Mon = 0
                    AND sked_events.Tue = 0
                    AND sked_events.Wed = 0
                    AND sked_events.Thu = 0
                    AND sked_events.Fri = 0
                    AND sked_events.Sat = 0
                    AND sked_events.Sun = 0
                    AND DAYOFMONTH(sked_events.starts_at) = :date_start_DAYOFMONTH
                    AND (:date_start_YEARMONTH - EXTRACT(YEAR_MONTH FROM sked_events.starts_at))
                        % sked_events.frequency = 0
                )';

            $strQuery .= '))';

        $strQuery .= ')' . $this->queryGroupAndOrder();

        // PDO
        return $this->queryPDO($strQuery, $this->aQueryParams + [
            ':date_start' => $strDateStart,
            ':date_start_NOTIME' => date('Y-m-d', strtotime($strDateStart)),
            ':date_start_DAYOFMONTH' => date('d', strtotime($strDateStart)),
            ':date_start_YEARMONTH' => date('Ym', strtotime($strDateStart)),
            ':date_end' => $strDateEnd,
        ]);
    }
protected function queryDay(string $strDateStart, string $strDateEnd)
    {
        $strQuery = $this->querySelectFrom($strDateStart)
            . $this->queryJoin()
            . $this->queryWhereNotExpired();

        // Happening today
        $strQuery .= ' AND (';

            // Original date matches
            $strQuery .= ' sked_events.starts_at BETWEEN :date_start AND :date_end';

            // Or it's already started and...
            $strQuery .= ' OR (sked_events.starts_at <= :date_start AND (';

                // Daily
                $strQuery .= ' (
                    sked_events.interval = "1"
                    AND (
                        DATEDIFF(
                            :date_start_NOTIME,
                            DATE_FORMAT(sked_events.starts_at, "%Y-%m-%d")
                        )/sked_events.frequency
                    ) % 1 =0
                )';

                // Day of week matches for weekly events
                $strQuery .= ' OR (
                    sked_events.interval = "7"
                    AND sked_events.' . date('D', strtotime($strDateStart)) . ' = 1
                    AND (
                        DATEDIFF(
                            :date_start_NOTIME,
                            DATE_FORMAT(sked_events.starts_at, "%Y-%m-%d")
                        )/7
                    ) % sked_events.frequency = 0
                )';

                // Monthly by day of week
                // Calculate how many months since first session, see if it's an exact match for today
                $strQuery .= ' OR (
                    sked_events.interval = "Monthly"
                    AND sked_events.' . date('D', strtotime($strDateStart)) . ' = 1
                    AND TIMESTAMPADD(
                        MONTH,
                        ROUND(DATEDIFF(:date_start, DATE_FORMAT(sked_events.starts_at, "%Y-%m-%d"))/30),
                        sked_events.starts_at
                    ) BETWEEN :date_start AND :date_end
                )';

                // Monthly by date
                $strQuery .= ' OR (
                    sked_events.interval = "Monthly"
                    AND sked_events.Mon = 0
                    AND sked_events.Tue = 0
                    AND sked_events.Wed = 0
                    AND sked_events.Thu = 0
                    AND sked_events.Fri = 0
                    AND sked_events.Sat = 0
                    AND sked_events.Sun = 0
                    AND DAYOFMONTH(sked_events.starts_at) = :date_start_DAYOFMONTH
                    AND (:date_start_YEARMONTH - EXTRACT(YEAR_MONTH FROM sked_events.starts_at))
                        % sked_events.frequency = 0
                )';

            $strQuery .= '))';

        $strQuery .= ')' . $this->queryGroupAndOrder();

        // PDO
        return $this->queryPDO($strQuery, $this->aQueryParams + [
            ':date_start' => $strDateStart,
            ':date_start_NOTIME' => date('Y-m-d', strtotime($strDateStart)),
            ':date_start_DAYOFMONTH' => date('d', strtotime($strDateStart)),
            ':date_start_YEARMONTH' => date('Ym', strtotime($strDateStart)),
            ':date_end' => $strDateEnd,
        ]);
    }
protected function queryDay ( string $ strDateStart , string $ strDateEnd ) { $ strQuery = $ this -> querySelectFrom ( $ strDateStart ) . $ this -> queryJoin ( ) . $ this -> queryWhereNotExpired ( ) ; // Happening today $ strQuery .= ' AND (' ; // Original date matches $ strQuery .= ' sked_events.starts_at BETWEEN :date_start AND :date_end' ; // Or it's already started and... $ strQuery .= ' OR (sked_events.starts_at <= :date_start AND (' ; // Daily $ strQuery .= ' (
                    sked_events.interval = "1"
                    AND (
                        DATEDIFF(
                            :date_start_NOTIME,
                            DATE_FORMAT(sked_events.starts_at, "%Y-%m-%d")
                        )/sked_events.frequency
                    ) % 1 =0
                )' ; // Day of week matches for weekly events $ strQuery .= ' OR (
                    sked_events.interval = "7"
                    AND sked_events.' . date ( 'D' , strtotime ( $ strDateStart ) ) . ' = 1
                    AND (
                        DATEDIFF(
                            :date_start_NOTIME,
                            DATE_FORMAT(sked_events.starts_at, "%Y-%m-%d")
                        )/7
                    ) % sked_events.frequency = 0
                )' ; // Monthly by day of week // Calculate how many months since first session, see if it's an exact match for today $ strQuery .= ' OR (
                    sked_events.interval = "Monthly"
                    AND sked_events.' . date ( 'D' , strtotime ( $ strDateStart ) ) . ' = 1
                    AND TIMESTAMPADD(
                        MONTH,
                        ROUND(DATEDIFF(:date_start, DATE_FORMAT(sked_events.starts_at, "%Y-%m-%d"))/30),
                        sked_events.starts_at
                    ) BETWEEN :date_start AND :date_end
                )' ; // Monthly by date $ strQuery .= ' OR (
                    sked_events.interval = "Monthly"
                    AND sked_events.Mon = 0
                    AND sked_events.Tue = 0
                    AND sked_events.Wed = 0
                    AND sked_events.Thu = 0
                    AND sked_events.Fri = 0
                    AND sked_events.Sat = 0
                    AND sked_events.Sun = 0
                    AND DAYOFMONTH(sked_events.starts_at) = :date_start_DAYOFMONTH
                    AND (:date_start_YEARMONTH - EXTRACT(YEAR_MONTH FROM sked_events.starts_at))
                        % sked_events.frequency = 0
                )' ; $ strQuery .= '))' ; $ strQuery .= ')' . $ this -> queryGroupAndOrder ( ) ; // PDO return $ this -> queryPDO ( $ strQuery , $ this -> aQueryParams + [ ':date_start' => $ strDateStart , ':date_start_NOTIME' => date ( 'Y-m-d' , strtotime ( $ strDateStart ) ) , ':date_start_DAYOFMONTH' => date ( 'd' , strtotime ( $ strDateStart ) ) , ':date_start_YEARMONTH' => date ( 'Ym' , strtotime ( $ strDateStart ) ) , ':date_end' => $ strDateEnd , ] ) ; }
Build the events query for today.

@param string $strDateStart Datetime that today starts.
@param string $strDateEnd Datetime that today ends.
@return array
Build the events query for today .