I am trying to use use a few conditions to select records based on start and end dates. Basically I want anything without an end date or that starts in the given period or ends in the same given period. Any help or direction on how this might be accomplished would be very appreciated. I'm including the WHERE part of the query below and the parameter binding but can include more if needed.
$periodsCxn->bindParam(':PositionID',$PositionID);
$periodsCxn->bindParam(':Start',$firstPayPeriod);
$periodsCxn->bindParam(':End',$lastPayPeriod);
$periodsCxn->bindParam(':Start2',$firstPayPeriod);
$periodsCxn->bindParam(':End2',$lastPayPeriod);
WHERE
POSITION_PERIOD.PositionID = :PositionID AND
(
(
POSITION_PERIOD.EndDate = '1900-01-01'
OR
POSITION_PERIOD.EndDate IS NULL
)
OR
(
POSITION_PERIOD.StartDate BETWEEN :Start AND :End
OR
POSITION_PERIOD.EndDate BETWEEN :Start2 AND :End2
)
)