INTERACT FORUM

More => Old Versions => JRiver Media Center 18 for Windows => Topic started by: Marra on July 12, 2013, 12:00:39 am

Title: Expression to find artist's start and end years
Post by: Marra on July 12, 2013, 12:00:39 am
I am trying to write an expression to calculate for every album artist (auto) the start date (ie the earliest album date) and the end date (ie the latest album date).
Just for display purposes in theater view.  End up with Bob Dylan (1960-2013) and similar for every album artist(auto).
I don't think I'm far off with using:
Initial
[=save(0,v_yearend[album artist (auto)])1]=1
Process
[=save(math(max([year]),load(v_yearend[album artist (auto)])),v_yearend[album artist (auto)])1]=1
Load
load(v_yearend[album artist (auto)])
to give the end date v_yearend.
And then similar for start date using v_yearstart and replacing max with min.
I think the error is occurring in using math and max on a date field (tried convertdate with no luck).
Any ideas?

Marra
Title: Re: Expression to find artist's start and end years
Post by: MrC on July 12, 2013, 12:18:32 am
Max requires two arguments:

   max(a,b)

and your paren closes the function call too quickly.

 [=save(math(max([year], load(v_yearend[album artist (auto)]))),v_yearend[album artist (auto)])1]=1

Also, don't forget to initialize the min value with some large year value such as 9999, since min() will always drop to 0 otherwise.
Title: Re: Expression to find artist's start and end years
Post by: Marra on July 12, 2013, 01:21:33 am
Yes that works.
Thanks again, you are a great teacher.