def nearby_valid_date(desired_date, dictionary):
    """
    Sometimes we get a date (year, month, day) that does not exactly exist in
    another dictionary. We want to find a nearby date that does exist in that 
    dictionary, but is part of the same month.
    """
    for valid_date in dictionary:
        if (valid_date[0:2] ==  desired_date[0:2]):  # matching year and month
            return valid_date