Page 1 of 1
Newbie - date matching on different date fomats

Posted:
Thu Feb 12, 2015 11:21 pm
by speedy_99
Hi,
I am a hazel newbie and want to know how to handle different date formats in my invoices (dd.mm.yyyy, dd-mm-yyyy, yyyy/mm/dd, yyyy/dd/mm, jan/dd/yyyy and so on)
I tested it with File Jugler, a windows software. There is only one token for all differnt date formats. It works pretty good and it works for all invoices with differnt date formats.
Is there a similar feature in hazel to avoid to create a token for any date format?
Sorry for my english.
speedy
Re: Newbie - date matching on different date fomats

Posted:
Fri Feb 13, 2015 12:16 pm
by Mr_Noodle
You can have multiple conditions for each format. If you re-use the same custom date attribute for each one, you will end up with only one attribute that you have to use in the actions. Basically, the first case to match is the one that gets used later.
Re: Newbie - date matching on different date fomats

Posted:
Fri Feb 13, 2015 6:56 pm
by speedy_99
Hey Mr_Noodle,
first thanks for you fast answere.
I fear I did not understand correct.
I understand, that I can reuse a token in diffrent actions, but is there one token that's recognizes all formats or do I have to create one for every format?
Can I combine "all" formates in one token?
It would be a lot of work, becaus there are many combinationes. And I would have to repeat them for every supplier Invoice.
This sounds a little bit stupid, so I imagine to be on the wrong path.
THX
Speedy
Re: Newbie - date matching on different date fomats

Posted:
Sun Feb 15, 2015 3:29 pm
by rjames86
You would do something like this:

Give your date token a name, and in the first rule, you'll set the format you're looking for:

Then in the second one, add your "My Date" token, choose the Edit Token again, and choose a different format

Then in your actions rules, you can use that one My Date date token to do whatever you want.
Re: Newbie - date matching on different date fomats

Posted:
Mon Feb 16, 2015 7:01 pm
by speedy_99
Hey rjames86,
Thank you for your help.
Your answer confirmed my guess. So I have to define any desired format. Then it is not like in file Juggler (Windows software). There is a variable "File Content: Date," which apparently includes "all" possible formats of date.
A question about your example:
Isn't the first variable "My Date" overwritten by the second edit? Or both formats now included???
What format will be used in a 2nd rule, if I reuse "My Date"?
But maybe I have only a brain blockade ...
Re: Newbie - date matching on different date fomats

Posted:
Tue Feb 17, 2015 12:24 pm
by Mr_Noodle
The first one to match is the value that is used. Since this is "any", it doesn't matter since Hazel will stop evaluating after the first one to match. If it were "all", then the subsequent uses of that attribute would have to match the value of the first one to match, regardless of the pattern set on it.
When you re-use the attribute, it has the format of the original one by default but you can change it. Each instance has a separate format from the others.
Also, Hazel doesn't do automatic detection because date formats are ambiguous. For example, in rjames86's example, it may not work properly for some dates like 01/05/06 which could be May 1, 2006 or May 6, 2001 (in his case, it will pick the first one because that one is matched first).
Re: Newbie - date matching on different date fomats

Posted:
Tue Feb 17, 2015 1:26 pm
by speedy_99
Thank you,
I think I understand