INTERACT FORUM

Please login or register.

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

Author Topic: Expression to find artist's start and end years  (Read 1285 times)

Marra

  • Regular Member
  • World Citizen
  • ***
  • Posts: 160
Expression to find artist's start and end years
« 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
Logged

MrC

  • Citizen of the Universe
  • *****
  • Posts: 10462
  • Your life is short. Give me your money.
Re: Expression to find artist's start and end years
« Reply #1 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.
Logged
The opinions I express represent my own folly.

Marra

  • Regular Member
  • World Citizen
  • ***
  • Posts: 160
Re: Expression to find artist's start and end years
« Reply #2 on: July 12, 2013, 01:21:33 am »

Yes that works.
Thanks again, you are a great teacher.
Logged
Pages: [1]   Go Up