Last week I was overjoyed at Hazel 3.1’s ability to do date matching, and I have been migrating my Hazel rules over to use this great new functionality.
One question was on my mind though: what happens when the document has multiple dates?
Default Date Behavior
I decided to do a test using one of my documents. For example, I have a statement with a date range like so:

I set up my Hazel rule as per David Sparks’ excellent screencast, and ended up with my date token:

In the “Do” section of the rule, I had it attach the reformatted date to the beginning of the file name:

As I suspected, the rule worked and it appears to have used the first date that it found, which in our case is 05/01/2013.

Choosing Your Hazel Date
I couldn’t find any way to have Hazel choose which date to use. However, awesome DocumentSnap reader Carsten Langrock had a great suggestion on Twitter: while we can’t choose the date, there are often words around the date that we can use to isolate it.
For example, take a look at my statement again. If I want 5/31/2013, there is that TO_ in there.

What would happen if I modified my Hazel token and put a TO and then a space before the date? That way, Hazel should consider that whole string when looking for the date.

What do you know. It pulled the date we were looking for and renamed the PDF appropriately.

This isn’t going to be possible with every PDF, but it should work for many of your documents if you are a bit creative.
Bonus lesson: if you want to see what Hazel sees when it looks at your documents, check out this ridiculously low tech way to extract text from a PDF.
Do you have other tricks for date matching with Hazel 3.1? Let us know in the comments. Thanks!