Problems applying "Date created" conditions

Get help. Get answers. Let others lend you a hand.

Moderator: Mr_Noodle

Problems applying "Date created" conditions Thu Aug 03, 2017 12:52 am • by kardvm
Hi Mr. Noodle,

I am having a problem using a Date condition, probably because I do not understand it fully. I am trying to create a file name for documents that reflect what part of the year they were sent to me. I need to split the documents into 2 different folders. The first folder is for documents I received between March 1, 2016 and before March 1, 2017. These documents should have 2016 added to the file name. The second folder receives the documents received between March 1, 2017 and before March 1, 2018, and they should have 2017 added to the file name. So, all of the documents received in 2017 need to be sorted around the March 1, 2017 date.

I have 2 rules, which are mostly identical except for a condition regarding the date the document was received. I have tried using the "Date created occurs before" and "Date created occurs after" conditions, followed by "12:00 AM" and "on the 1st of Mar", but the rules fail to match. If I change the conditions to "Date created is after" or "Date created is before" "specific date" "3/1/2017, 12:00 PM", the conditions do match with the appropriately dated documents. The problem with using the "specific date" conditions is that every new year I would have to go back in and manually change the year of the "specific date".

Is there something I am not doing correctly when I apply the "Date created occurs after" and Date created occurs before" conditions?

Thank you,
Ken
kardvm
 
Posts: 14
Joined: Tue Feb 22, 2011 12:07 pm

Upon further reflection, I may have found the answer to my own question. I seemed to have misunderstood the span of time that the "occurs before" or "occurs after" refer to. It now appears to me that the maximum span of time for comparison is 24 hours. If that is correct, I will have to look for another way of sorting dates by the month of the year.

And if that is the case, it would be useful to have more granular control for comparing dates, such as by the specific quarter of the year, or by the value of the date (for comparison purposes, as can be done in spreadsheets and data bases).

Your thoughts on this would be appreciated.

Ken
kardvm
 
Posts: 14
Joined: Tue Feb 22, 2011 12:07 pm

Not sure what you mean by "value of the date" but when using "occurs before" or "occurs after", you need to keep in mind that it has to satisfy all the conditions.

If you do before a specific time on March 1, that doesn't mean every point before March 1 forever. It only applies as long as it is March 1st and before that specific time. The point of the feature is for things happening at a re-occurring frequency. If you want to include all the days of a quarter, for instance, you'll need to specify all the actual days, either by selecting the specific months or every date in the month.
Mr_Noodle
Site Admin
 
Posts: 11872
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Thank you for that information, Mr. Noodle,

After playing around with setting specific months, with or without adding in the days of the month or the days of the week, it appears that no matter how many days, or months, are included in the criteria for the condition "occurs before" or "occurs after", each included day is evaluated separately over its own 24 hour period. Therefore, no matter how I set up the condition, the range that is evaluated never extends outside the bounds of the 24 hour period of the earliest day and the 24 hour period of the latest day in the range. If the date that I am evaluating is somewhere within that range, the condition matches, otherwise it does not. I now understand more completely what you explained to me in your last post.

So my original problem, brought on by my inherent laziness, remains. So far, the best form of the condition that I am looking for is "Custom Date is before specific date 3/1/2017, 12:00 AM". By specifying the year in that condition, I assume that on January 1 of every year I will have to manually adjust those dates. Do you know of any way that I can modify this condition so that the year (2017) does not have to be specified?

Ken
kardvm
 
Posts: 14
Joined: Tue Feb 22, 2011 12:07 pm

Can you post screenshots of how you have it set up?
Mr_Noodle
Site Admin
 
Posts: 11872
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Hi Mr. Noodle,

I had to give up on using the Date functions that Hazel provides. With the condition shown below, I could only get a match if the date in the document file was a date in March. And I had no way to automatically change the year in that condition.

/Users/Ken/Desktop/Screen Shot 2017-08-04 at 7.15.11 PM.png

After spending some quality time reading the Hazel Help file, I resorted to using an embedded AppleScript. The next two screenshots show the set up that works. The value of the present year is always provided by using "current date" in AppleScript. The only other difference in the two rules is that I modified the Custom Date token "documentDate" in the first rule to subtract one year from the "current date" in the AppleScript. This change makes it possible to rename each document with the value of this year or of last year, as needed.

/Users/Ken/Desktop/Screen Shot 2017-08-04 at 5.45.44 PM.png

/Users/Ken/Desktop/Screen Shot 2017-08-04 at 6.35.47 PM.png

The next two screen shots show the AppleScript that I used and its minor variation.

/Users/Ken/Desktop/Screen Shot 2017-08-04 at 7.10.19 PM.png

/Users/Ken/Desktop/Screen Shot 2017-08-04 at 7.11.31 PM.png

I have learned a lot about both Hazel and AppleScript that I did not know. My requirements usually do not take me this deep into Hazel.

Thank you for your interest in my problem.

Ken
kardvm
 
Posts: 14
Joined: Tue Feb 22, 2011 12:07 pm

Hi again,

I cannot see the screen shots that I posted. If .png is the wrong format, let me know and I will resubmit them,

Ken
kardvm
 
Posts: 14
Joined: Tue Feb 22, 2011 12:07 pm

You need to upload your images to a hosting service then link them in your post. imgur.com is one such service but if you use something like Dropbox, you can share image links that way.
Mr_Noodle
Site Admin
 
Posts: 11872
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Hi Mr. Noodle,

I think I have things sorted out now. I was confused by the other posts that display screen shots. So now I know that drag and drop will not work here.

I use Dropbox, but I have not shared any files for a long time, and Dropbox has changed things in the meantime. I have put a folder named Hazel Rules in Dropbox. I will put the link to that folder below. The folder contains the five screenshots that I referred to in my previous post. The files are numbered 1 to 5, and are in the same order as I referred to them in my previous post.

https://www.dropbox.com/sh/nmw58qc86xyt ... UvOea?dl=0

Ken
kardvm
 
Posts: 14
Joined: Tue Feb 22, 2011 12:07 pm

If you want this to be a repeating thing every year, then use "occurs before". Make sure that the pattern there covers all days for the quarter. You can specify this by selecting the appropriate months. If you can't get that working, post a screenshot of that part of the rule.
Mr_Noodle
Site Admin
 
Posts: 11872
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Hi Mr. Noodle,

I now see what my mistake was. Before, when you described how the condition "occurs before" works when days or months are specified, I was still thinking along the lines of using the comparisons "greater than" and less than". So whenever I tried a new combination of days and months, the Date Created of the file I was trying to match was always outside of the 24 hour bounds of any of the days or months listed in the condition. I did not understand that if the date the file was created was 2/20/2017 at 12:16 PM, the specific time that I would use to compare it to also had to be a time that occurred on 2/20/2017, and that the time used to compare with had to be later than the time the file was created. But, since I was focused on "greater than" and "less than" comparisons, I was always trying to do something with March 1, in order to encompass the entire months of January and February, 2017.

So now I have created a condition that says "Date Created occurs before 11:59 PM on the (every day of the month) of Jan or Feb". That condition works as well as the AppleScript that I used, it completely covers the period of 2017 before March 1, and those files that match will have the previous year (2016) appended to their file names.

This process has been very interesting, and I have learned more about Hazel and AppleScript at the same time.

Thank you.

Ken
kardvm
 
Posts: 14
Joined: Tue Feb 22, 2011 12:07 pm

Thank you. This thread was extremely useful to me. I've collapsed years worth of monthly rules for three different types of accounting files down into a total of six rules that will cover every year. Brilliant. Accounting documentation for my accountant made easy.
PaddyPatPat
 
Posts: 4
Joined: Sun Apr 10, 2016 10:12 am


Return to Support