Given the vagaries of date math (e.g., does this particular February have 28 days, or does this one have 29?), you might have better luck inverting the search. First build a list of ($year, $month, $day) triples that represent the dates within your search range, and then look to see if there's a corresponding file.