dates = [datetime.datetime(2007, 1, 2, 0, 1), datetime.datetime(2007, 1, 3,
    0, 2), datetime.datetime(2007, 1, 4, 0, 3), datetime.datetime(2007, 1, 
    5, 0, 4), datetime.datetime(2007, 1, 6, 0, 5), datetime.datetime(2007, 
    1, 7, 0, 6)]
within = [date for date in dates if datetime.datetime(2007, 1, 3) < date <
    datetime.datetime(2007, 1, 6)]
Compare list of datetimes with datetime in Python