Bloom filters could do it. https://en.wikipedia.org/wiki/Bloom_filter
Also, the Unix approach can do something like this by spitting out days at a time and sorting them, and then doing a
sort -m "$month/*" | uniq -c
on the individual files.`sort -m` takes basically no memory, and should chew through data fast enough.