INTERACT FORUM

Please login or register.

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

Author Topic: calculated field for decade of album release  (Read 4001 times)

nickharambee

  • Regular Member
  • Galactic Citizen
  • ****
  • Posts: 365
  • doh!
calculated field for decade of album release
« on: November 26, 2006, 04:40:11 am »

one of my user defined fields in MC is 'decade', pretty self-explanatory, the decade of each album's release, 50s, 60s, etc.  i also have a field for the year of release of each album.  is it possible to set up my 'decade' field so that it will automatically calculate the correct decade from the year of release field, or will i have to do this manually? 

thanks

nick
Logged

marko

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 9139
Re: calculated field for decade of album release
« Reply #1 on: November 26, 2006, 05:16:18 am »

Quote
is it possible to set up my 'decade' field so that it will automatically calculate the correct decade from the year of release field?

Yes. You would change your decade field to be 'calculated data' and then create an expression using the "mid()" function.

Something like this perhaps?

if(isempty([date]),No Date,mid([date],2,1)0s)

nickharambee

  • Regular Member
  • Galactic Citizen
  • ****
  • Posts: 365
  • doh!
Re: calculated field for decade of album release
« Reply #2 on: November 26, 2006, 05:40:42 am »

thanks marko

works a treat.  could you alter the expression so that the decades read 1920s,1930s, etc. rather than 20s, 30s, etc.  not sure how to do this.

nick
Logged

EpF

  • Citizen of the Universe
  • *****
  • Posts: 649
Re: calculated field for decade of album release
« Reply #3 on: November 26, 2006, 06:18:42 am »

thanks marko

works a treat.  could you alter the expression so that the decades read 1920s,1930s, etc. rather than 20s, 30s, etc.  not sure how to do this.

nick
The mid() function returns a sequence of characters in a field, so in the brackets you put the field, the character position you want it to begin searching from (0 for the first character), and the number of characters you want it to return, so:

if(isempty([date]),No Date,mid([date],0,3)0s)

gives you the date field searched from character 0 and returning a total of 3 characters.

Check out this page for basic explanations of all the expression functions etc..
http://www.jrmediacenter.com/DevZone/DBExpressions.htm

You might want to specify "[date (year)]" in the expression, in case you have any files with the full day/month/year information.

nickharambee

  • Regular Member
  • Galactic Citizen
  • ****
  • Posts: 365
  • doh!
Re: calculated field for decade of album release
« Reply #4 on: November 26, 2006, 06:25:12 am »

perfect!!

thanks a lot
Logged

MP101User

  • Junior Woodchuck
  • **
  • Posts: 77
Re: calculated field for decade of album release
« Reply #5 on: May 22, 2007, 01:40:21 pm »

Thought I'd try the suggestion in this thread fo a new topic. Managed to stuff it up somehow. I get four boxes after every decade: almost like it's displaying characters that aren't supported by the font.

My expression is simply mid([date (year)],0,3)0s but I get decades from 1920s#### to 2000s#### where the # represents a large (one character) square hollow box.

Can anybody see what I've done wrong?  ?

Regards,

M.
Logged

marko

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 9139
Re: calculated field for decade of album release
« Reply #6 on: May 30, 2007, 04:30:57 am »

looks fine to me.
Where abouts in MC are you using the expression?

MP101User

  • Junior Woodchuck
  • **
  • Posts: 77
Re: calculated field for decade of album release
« Reply #7 on: May 30, 2007, 06:41:14 am »

It was in the expression editor under the "edit view scheme" window.

And as I went there to find the name of the window, I foun the problem.
The expression was followed by two carriage returns. Impossible to see in the editor, but they show up in the view scheme.

All sorted.
Thanks for the reply, which led me towards the solution.

M.
Logged
Pages: [1]   Go Up