INTERACT FORUM

Please login or register.

Login with username, password and session length
Advanced search  
Pages: [1]   Go Down

Author Topic: Smartlist Current Year  (Read 388 times)

MrFadedGlory

  • Member
  • *
  • Posts: 3
Smartlist Current Year
« on: November 20, 2020, 06:45:46 pm »

Hello all, newbie to smartlists here. I'm trying to create a smartlist that includes albums released "this year". In my mind, this would be a list that flipped over every year, making it easy for me to compile my personal "best of" at the end of each year. I can get things to work if I just hard code [Date(year0] = 2020, but that takes some of the smarts away from the list. I've tried playing around with the now() expression, but I can't get things to work. Could be my expression, could be where I'm trying to paste it, could be something else. Any suggestions? Thanks!
Logged

glynor

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 19608
Re: Smartlist Current Year
« Reply #1 on: November 20, 2020, 06:55:37 pm »

Just to be clear, you want only tracks released in the current calendar year, not within the past 365 days (rolling year), correct? So the list should be empty on January 1?
Logged
"Some cultures are defined by their relationship to cheese."

Visit me on the Interweb Thingie: http://glynor.com/

MrFadedGlory

  • Member
  • *
  • Posts: 3
Re: Smartlist Current Year
« Reply #2 on: November 20, 2020, 07:09:10 pm »

Correct. Not a rolling 365 days, but actual calendar year.
Logged

marko

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 8954
Re: Smartlist Current Year
« Reply #3 on: November 20, 2020, 07:32:24 pm »

So, you need to compare the current year with the date of the album, and keep the matches, discarding the rest...

The current year...
formatdate(now(),yyyy)

And, your album dates...
formatdate([date,0],yyyy)

the compare:
isequal(formatdate(now(),yyyy),formatdate([date,0],yyyy),2)

The above is your basic expression, it returns a 1 for a positive match, and zero for a negative match. What happens next, depends upon how and where you want to use it. As a smartlist rule, wrap it like so...
Code: [Select]
[=isequal(formatdate(now(),yyyy),formatdate([date,0],yyyy),2)]=1
Press the import/export button on the smartlist editor and paste the following...
Code: [Select]
[Media Type]=[Audio] [=isequal(formatdate(now(),yyyy),formatdate([date,0],yyyy),2)]=1
OK your way out, and smile :) This smartlist will always list results from the current year.

You were poking around in the correct area with the now() function, so, fair to assume you found this page on the wiki?
https://wiki.jriver.com/index.php/Expression_Language#Function_Index

now() allows us to do some nifty stuff. Some examples are here:
https://yabb.jriver.com/interact/index.php/topic,102319.msg709847.html#msg709847

The expression is wrapped like so [=expression]=1 (or 0) for use in searches, which is what a smartlist essentially is, a saved search.

I don't have links for dates, but there are several posts detailing MC's unix date handling. The formatdate() function will not work with a formatted date. By inserting the zero inside the library field reference, we are instructing the evaluator to use the raw date data, [Date,0], returning the date in a readable fashion, formatted as specified.

These little tips are all expanded upon and better knitted together on that wiki page, and the examples linked within it, but repeated here to better assist with understanding what the expression is doing, and spur onwards to explore what more you could come up with :)

-marko

MrFadedGlory

  • Member
  • *
  • Posts: 3
Re: Smartlist Current Year
« Reply #4 on: November 20, 2020, 07:39:14 pm »

Thanks marko. Perfect. Works like a charm. It would have taken me hours of trial and error to figure that out, but it makes sense when I read your code.

BTW, I'm also setting [Total Tracks]=>5 in my rules to filter out anything that's smaller than an EP. Might be a fancier way of doing that, but this seems to get the job done.

Appreciate the help!
Logged
Pages: [1]   Go Up