title: How to restrict SQL query to read current date ranges only?
body: <p>A student is currently enrolled in Management Stream with a start date of 08/28/2021 and end date of  12/31/2021.
  The student is switching stream from Science(S) to Management (M).The Paycode is also changing (current= 'H', to Future 'L').
  with a start date of 01/01/2022 and end date of 12/31/2026.</p>
  <p>An Access database table has two start_dates(08/28/2021 and 08/01/2022), two end_dates(12/31/2021 and 12/31/2026), two Streams ('S' and 'M') and two paycodes('H' and 'L').
  The logic below is picking up (or probably mixing things up) the start dates, end dates, streams and paycodes randomly and thus producing fallouts.
  Is there a way to force the logic/code to restrict it to look at the start and end dates, stream and paycode to these (08/28/2021,12/31/2021,'S','H') until 12/31/2021?
  And also need to tell it to check the (01/1/2022,12/31/2026,'M','L') on or after 01/01/2022.
  Any help is greatly appreciated.</p>
  <pre><code>proc sql;
      create table detail as
          select distinct 
              a.student_ID,           
              case when b.studentId = '' then 'Row not found in StudentInfo' else '' end as Row_Check,
              case when b.studentId ^= '' and a.subject_name ^= b.SubjName then 'Unmatched Subject Name' else '' end as Subject_Check,
              case when b.studentId ^= '' and a.pay_code ^= b.paycode then 'Unmatched Pay Code' else '' end as PayCode_Check,
                          case when b.studentId ^= '' and a.stream_code ^= b.Streamcode then 'Unmatched Stream Code' else '' end as Stream_Check,
                      case when b.studentId ^= '' and (a.start_date &lt; b.StartDate) or (a.end_date &gt; b.EndDate) then 'Date Range not Allowed' else '' end as EnrollmentDate_Check,
                          a.student_name,
              a.subject_name,
              a.start_date,
              a.end_date,         
              a.participation_code,
              a.pay_code                  
          from student_data a
              left join StudentInfo b
                  on b.studentId = a.Student_ID and b.section = a.section 
          having row_check ^= '' or subject_check ^= '' or Paycode_Check ^= '' 
                 or Stream_Check ^= '' or date_check ^= ''
          order by a.student_ID, a.student_name;
  
  quit;
  </code></pre>