Understanding the DATE function coupled with NOW

Discussion related to "Everything" 1.5 Alpha.
Post Reply
ChrisGreaves
Posts: 684
Joined: Wed Jan 05, 2022 9:29 pm

Understanding the DATE function coupled with NOW

Post by ChrisGreaves »

I thought to use Search Functions to locate all document files that had been modified on the first day of any month this year. Ambitious I know, but ...
The supplied example from the foot of this post suggested
ext:doc dm:[year:now:]
as a starting point and this appeared to work fine. 465 objects it said, which works out to about 100 documents each month. perhaps a bit high, but possible
Emboldened I tried "ext:doc dm:[day:now:]" but as far as I can determine, the results include 153 documents, documents that have the digit "1" somewhere in the date (today is the First of May here in Newfoundland) :-
SearchFunctions_04.png
SearchFunctions_04.png (59.8 KiB) Viewed 704 times
I tried also "ext:doc dm:[hour:now:] at around 1630 this afternoon and this seemed to return documents that have the digit-string "16" somewhere in the date:-
SearchFunctions_03.png
SearchFunctions_03.png (64.85 KiB) Viewed 704 times
Maybe Everything and I have failed to communicate date formats between us?

Comments welcomed, especially as this is my first real foray into Search Functions.
Thanks, Chris
therube
Posts: 4985
Joined: Thu Sep 03, 2009 6:48 pm

Re: Understanding the DATE function coupled with NOW

Post by therube »

Thinking you have to do this from the command line, passing the function.

C:\DEV\LOCATE>everything.exe -s [year:now:]


And what is passed, is what [year:now:] resolves to.
So the above would (currently) send:
Everything -s 2023
as in the string "2023" is being sent.

Now you can combine dm: & ext:, likewise:
C:\DEV\LOCATE>everything -s dm:[year:now:] ext:txt

Which is the same as:
Everything -s dm:2023 ext:txt



Likewise:
C:\DEV\LOCATE>everything -s dm:[day:now:] ext:txt

Is sending:
Everything -s dm:1 ext:txt


Note that it is ending "dm:1", which is kind of meaningless, as in it will not be giving you the results you are after.
Compare that to:
Everything -s dm:today ext:txt

(dm:today can be run from the Everything searchbar.)
ChrisGreaves
Posts: 684
Joined: Wed Jan 05, 2022 9:29 pm

Re: Understanding the DATE function coupled with NOW

Post by ChrisGreaves »

therube wrote: Mon May 01, 2023 7:45 pm Thinking you have to do this from the command line, passing the function.
TheRube, thank you for miraculously extending my knowledge. In summary:-
C:\Program Files\Everything 1.5a>everything64.exe -s [year:now:] works (5,075 objects)
C:\Program Files\Everything 1.5a>everything64.exe -s dm:[year:now:] ext:txt works (600 objects)
C:\Program Files\Everything 1.5a>everything64.exe -s dm:[day:now:] ext:txt works, but as you point out, “which is kind of meaningless, as in it will not be giving you the results you are after.”. It returns 50 objects from 2022, and the day number ranges from 1 to 31.

That leaves me with a puzzle which I will ponder as I walk to the grocery store.
When my human brain sees a date-like function, for example the construction "dm:[year:now:]" my weak human brain thinks of dates.
Likewise "dm:[hour:now:]" makes me think of the hour of the current time of day (eleven o'clock as I type)

So when I associate this hour-value ("11") with a date-time construction, my human brain thinks along the lines of "Oh come ON! You can SEE that I am interested in the hour-of-day. Match the result of this hour-value ("11") with the hour-portion of the date-time in the date Modified field.

This is what makes other people (not me!) say "Stupid Computer!"

I am not sure how to address this, which is why I need to think for a while.

In the immediate sense I will remember that the pre-processor, macro-processor thinks only in terms of strings, without considering the context of the strings. " [year:now:]" is just another way of typing a four-digit string "2023" and does NOT generate a year-value of 2023.
But of course I don't want to be responsible for writing a more complex pre-processor.

More later ...
Thanks again, chris
Post Reply