A better idea for "before 10 years" ...

Started by sinus, February 02, 2024, 09:12:22 PM

Previous topic - Next topic

sinus

Hello
Sometimes it would be interesting to check the database in a simple way, what was in my DB

- 5 years ago
- 10 years ago
- 50 years ago
...

You can see this sometimes, when some newspapers or the TV/radio does something like this: "50 years ago today the following happened ..."
 
It should be as accurate as possible x years ago. To be honest, I can't get it exactly right.
And I may have taken the wrong path, perhaps there is a much better way.

I have created a DataDriven category with this variable:

{Application.DateTime|format:YYYY-MM-DD hh:mm:ss;math:timediff,{File.DateTime|format:YYYY-MM-DD hh:mm:ss};math:div,31557600,5;replace:,==.;between:0.994,1.006,a 1 Jahr her,;between:1.994,2.006,b 2 Jahre her,;between:2.994,3.006,c 3 Jahre her,;between:3.994,4.006,d 4 Jahre her,;between:4.994,5.006,e 5 Jahre her,;between:9.994,10.006,f 10 Jahre her,;between:14.994,15.006,g 15 Jahre her,;between:19.994,20.006,h 20 Jahre her,;between:29.994,30.006,i30 Jahre her,;between:39.994,40.006,j 40 Jahre her,;between:49.994,50.006,k 50 Jahre her,;between:59.994,60.006,l60 Jahre her,;between:69.994,70.006,m70 Jahre her,;between:79.994,80.006,n80 Jahre her,;between:89.994,90.006,o 90 Jahre her,;between:99.994,100.006,p 100 Jahre her,;between:1119.994,120.006,q 120 Jahre her,;between:149.994,150.006,r 150 Jahre her,;between:199.994,200.006,s 200 Jahre her,;between:299.994,300.006,t 300 Jahre her,;between:399.994,400.006,v 400 Jahre her,;between:499.994,500.006,w 500 Jahre her,}
This works pretty well, of course it has some variance in the result, a few days before or after, but that's not so bad.
After all, only relatively few of my 370,000 files are fished out.

In any case, it works this way, but perhaps there is a more elegant way?
Does anyone have a better idea for realising something like this?

In the attachement you can see my results.
Best wishes from Switzerland! :-)
Markus

JohnZeman

Marcus as my feeble old brain cells seem to recall there was a forum thread about this a few years ago.  It led to the creation of a formula category that returns the images in the database that were taken on the current date but in different years.

I've been using that formula category with a data driven category ever since and the combination of the two works great for me.

I've attached a screen shot of the formula category, it's a big one for sure but it hopefully it'll show you how to make one for yourself.

I've also attached a screen shot of the data driven category which uses the formula category along with a screen shot of how it looks in my Category View.

sinus

Hi John
Thanks a lot for your work and thanks to your very good brain, even it is not more the youngest. :)
I will have a close look at your way, seems promising.

There are several ways to Rome, as we say here sometimes. And specially IMatch has often really several ways to solve a problem.

Best wishes from Switzerland! :-)
Markus

Mario

-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

sinus

@Mario:
Thanks for your input. Using the "today over the years" in the Event-View is for sure interesting and very good, but I think, this uses only images, used in Events.
And I want searching the whole DB.

@John
Your idea is really great, and if it works for you: super!
But I would have to create categories first and then I became another idea for a better variable, what is much more precise.
I did it on this way, that the variable gives results back from TODAY back 1 year, 2 year, 5 years, 20 years and so on.

But because I want e.g. congrats for a friend for his 10 wedding-day, this is a bit short, hence I added also one day back.
Means, if today is the 5. of february, it should give results back from e.g. 5. feb. 2013 AND also from 4. feb. 2013.
This gives me a day more time to react.  :)

With my test this variable works quite exactly.
I use it in a Data-driven - category and works very well.

The only thing is, if you took 300 images on an event (like wedding), all 300 will be displayed.
It would be cool, if I could show only the master of stacked images, because I have stacked all images from events, football-games, parties, holydays of whatever.

But this is of course a small "pity" and who knows, maybe quite good to check from time to time a stack.  ;D

Because your system works well, you will not need this, but I add here the variable (for DD-cats) anyway:

{Application.DateTime|format:YYYY-MM-DD;math:timediff,{File.DateTime|format:YYYY-MM-DD};between:15723000,15968000,a-- 6 Monate her,;between:31446000,31536000,b-- 1 Jahr her,;between:62982000,63072000,c-- 2 Jahre her,;between:94518000,94608000,d-- 3 Jahre her,;between:126140400,126230400,e-- 4 Jahre her,;between:157676400,157766400,f-- 5 Jahre her,;between:315442800,315532800,g- 10 Jahre her,;between:473209200,473299200,h- 15 Jahre her,;between:631062000,631152000,i-- 20 Jahre her,;between:788918400,788918400,j-- 25 Jahre her,;between:946594800,946684800,k- 30 Jahre her,;between:1104361200,1104451200,l-- 35 Jahre her,;between:1261404000,1262304000,m- 40 Jahre her,;between:1421980400,1420070400,n- 45 Jahre her,;between:1577746800,1577836800,o- 50 Jahre her,;between:1735513200,1735603200,p- 55 Jahre her,;between:1893366000,1893456000,q- 60 Jahre her,;between:2051132400,2051222400,r-- 65 Jahre her,;between:2208898800,2208988800,s- 70 Jahre her,;between:2366665200,2366755200,t-- 75 Jahre her,;between:2524518000,2524608000,u- 80 Jahre her,;between:2682284400,2682374400,v- 85 Jahre her,;between:2840050800,2840140800,w- 90 Jahre her,;between:2997817200,2997907200,x- 95 Jahre her,;between:3155670000,3155760000,y--100 Jahre her,;between:3471202800,3471292800,z--110 Jahre her,;between:3786822000,3786912000,za-120 Jahre her,;between:4102268400,4102358400,zb-130 Jahre her,;between:4417887600,4417977600,zc-140 Jahre her,;between:4733420400,4733510400,zd-150 Jahre her,;between:5680191600,5680281600,ze-180 Jahre her,;between:6311343600,6311433600,zf-200 Jahre her,;between:7889094000,7889184000,zg-250 Jahre her,;between:9467017200,9467107200,zh-300 Jahre her,;between:12622690800,12622780800,zi---400 Jahre her,}
Best wishes from Switzerland! :-)
Markus

sinus

Hi
After a few attempts, I found a variable that does what I was looking for. Hopefully it is correct, what I think.  8)

The following variable is the most accurate. Because it simply ignores the seconds and only compares the year, month and day with the same format from today.
This also eliminates problems with leap years that occur with other calculation methods.

In my opinion, a variable with "timediff" is very accurate, but even it cannot completely avoid the "problem" with leap years, if you want it very exactly.
This is because, depending on the current time and the time of day at which a photo was taken, the calculations can result in a day earlier or later. Which of course is pretty accurate, but the variable here seems to be better in this case.

It simply takes the current date using the Application.DateTime variable in the format
YYYYMMDD
and subtracts this number from the images with File.DateTime.

If it is the same, the result is 0.
After one year, the result is 10000 and, for example, 150000 for 15 years.
Now you can compare these numbers with "is:", if true, add some words, if not, then leave it blank (with the coma after the wished words) - and that's it.

If you want to try this, simply create a DataDriven category, insert the variable and switch off "Others". Then you only get the files that were created exactly 10, 20 or 150 years ago, etc.

{Application.DateTime|format:YYYYMMDD;math:sub,{File.DateTime|format:YYYYMMDD};is:10000,01 vor 1 Jahr,;is:20000,02 vor 2 Jahren,;is:30000,03 vor 3 Jahren,;is:40000,04 vor 4 Jahren,;is:50000,05 vor 5 Jahren,;is:60000,06 vor 6 Jahren,;is:70000,07 vor 7 Jahren,;is:80000,08 vor 8 Jahren,;is:90000,09 vor 9 Jahren,;is:100000,10 vor 10 Jahren,;is:110000,11 vor 11 Jahren,;is:120000,12 vor 12 Jahren,;is:130000,13 vor 13 Jahren,;is:140000,14 vor 14 Jahren,;is:150000,15 vor 15 Jahren,;is:160000,16 vor 16 Jahren,;is:170000,17 vor 17 Jahren,;is:180000,18 vor 18 Jahren,;is:190000,19 vor 19 Jahren,;is:200000,20 vor 20 Jahren,;is:250000,25 vor 25 Jahren,;is:300000,30 vor 30 Jahren,;is:350000,35 vor 35 Jahren,;is:400000,40 vor 40 Jahren,;is:450000,45 vor 45 Jahren,;is:500000,50 vor 50 Jahren,;is:550000,55 vor 55 Jahren,;is:600000,60 vor 60 Jahren,;is:650000,65 vor 65 Jahren,;is:700000,70 vor 70 Jahren,;is:750000,75 vor 75 Jahren,;is:800000,80 vor 80 Jahren,;is:900000,90 vor 90 Jahren,;is:950000,95 vor 95 Jahren,;is:1000000,a-0 vor 100 Jahren,;is:1200000,b-0 vor 120 Jahren,;is:1500000,c-0 vor 150 Jahren,;is:2000000,d-0 vor 200 Jahren,;is:2500000,e-0 vor 250 Jahren,;is:3000000,f-0 vor 300 Jahren,;is:3500000,g-0 vor 350 Jahren,;is:4000000,h-0 vor 400 Jahren,;is:450000,i-0 vor 450 Jahren,;is:500000,j-0 vor 500 Jahren,}

btw:
(d-0 vor 200 Jahren and so on means simply "200 years ago" and the d-0 is one possibility to make the sorting correct, I found no other way for this)

Hopefully this makes sense, at least here this works fine, see attachement.  :)
Best wishes from Switzerland! :-)
Markus

Tveloso

Thank you Markus, I like the approach of referring to the "Years Ago" values instead of the Years themselves...and simply subtracting the two ISO dates is a great idea!

If we employ the mod function, then we don't have to refer explicitly to the various "Years Ago Values" in an is, and can simply divide by 10,000 to get the years value directly...and the variable then gets quite a bit more compact:

{Application.DateTime|format:YYYYMMDD;math:sub,{File.DateTime|format:YYYYMMDD};math:mod,10000;is:0,vor {Application.DateTime|format:YYYYMMDD;math:sub,{File.DateTime|format:YYYYMMDD};math:div,10000;numformat:int,03} Jahren,}

I just updated my "Today over the years" Category, which previously used this variable:

{File.DateTime|format:MM-DD;is:{Application.DateTime|format:MM-DD},{File.DateTime|format:YYYY},}
...as we discussed here some time ago, which returned the Year Values:

    Screenshot 2024-02-13 150042.png

...to now use your variable, and return the "Years Ago" Values instead of the Years:

    Screenshot 2024-02-13 152452.png

It's just amazing all the options that IMatch gives us!
--Tony

sinus

#7
Hi Tony
Wow, thanks a lot for your sophisticated input.
And make variables more compact, is a good idea either way.

I checked this out and - wonderful!
It is amazing, what can be done with a quite short variable!
Thanks a lot, you did it very good.

To be honest, I have read once the mod-thing, but because of my unfortunately very poor understanding of maths, I couldn't understand it and left it.

I work a lot with variables and I'm sure that if I had paid more attention at school, it would help me a lot now. :)

And yes, IMatch gives us really a lot of good stuff, and I am happy, that Mario introduced once some "math-functions". I can remember this, it is quite some years ago.
And the mod-stuff, he has added it later, this is not sooo long since.

update:
Tony, I played a bit with your variable ... Amazing!
I added at the end some replace-stuff, it improves the visual appearance a little, but of course you can see it either way, I like it a bit more.

{Application.DateTime|format:YYYYMMDD;math:sub,{File.DateTime|format:YYYYMMDD};math:mod,10000;is:0,vor {Application.DateTime|format:YYYYMMDD;math:sub,{File.DateTime|format:YYYYMMDD};math:div,10000;numformat:int,03} Jahren,;pereplace:vor 001 Jahren==vor __1 Jahr;pereplace:vor 00==vor __;pereplace:vor 0==vor _}
Best wishes from Switzerland! :-)
Markus

sinus

here is a screenshot with your variable, Tony.

Best wishes from Switzerland! :-)
Markus

jch2103

Thanks, Tony! I used your variable w/ small modifications for English:

{Application.DateTime|format:YYYYMMDD;math:sub,{File.DateTime|format:YYYYMMDD};math:mod,10000;is:0,for {Application.DateTime|format:YYYYMMDD;math:sub,{File.DateTime|format:YYYYMMDD};math:div,10000;numformat:int,03} Year(s) Ago,}
I'll next have to adapt the additional formatting Markus employed. 

Very useful!

John

Tveloso

The innovative approach that Markus gave, of simply subtracting the two ISO Dates, to both:

    1.) Identify files dated on an anniversary of Application.DateTime: 00150000

...and:

    2.) Give the number of years of that anniversary: 00150000

...is what lies at the heart of that variable.

The addition of the modulus function was just a little refinement that thankfully streamlined the variable nicely.

IMatch Variables are so powerful...(I continue to be in awe of what Mario has created with IMatch!)...

--Tony