The link in this old post no longer works. As of September 2023 it is not necessary to use a script to pull the date from a bank statement. This is how you would get a date from a bank statement and use it as part of the file name:

Note that before the "Date" variable I have put the word "to". This is to distinguish the statement date from all the other dates on the pdf. The bit I want to find is part of this text in red: "From 1 October 2022
to 31 December 2022".
Note that you may need to manaully specify the date format if Hazel does not detect it automatically. This is how you do it (click on the downward pointing arrow after "Date")

Then I rename the file with the date at the front of the file name in the pattern yyyy-mm-dd. You can use a date format which you can manually specify, if you don't like the default format, like this:
