INTERACT FORUM

Please login or register.

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

Author Topic: Library Field issue. Using an Expression changes the data type  (Read 351 times)

rbmjr

  • World Citizen
  • ***
  • Posts: 112

Would it be possible to upgrade the Library Field(s) dialog to fix the problem that I encounter when I use an expression with a library field. My issue is that I create a Library Field with the data type of "Date". Then I go to the Expression field and enter "=[Last Played,0]" However, as soon as I choose to enter an Expression, the data type that was "Date" turns to "String" and the value placed in the field is a string value and no longer works as a date value. If I remove the Expression field and set the data type back to "Date" I can fill the field correctly by adding an Expression column in a Smartlist Playlist using "SetField(SmartDate,[Last Played,0])" though I'd rather the Library Field update itself whenever the Last Played date changes than for me to have to run a smartlist playlist to make this happen. Can you help me with this?
Logged

lepa

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 1978
Re: Library Field issue. Using an Expression changes the data type
« Reply #1 on: August 09, 2023, 05:42:29 pm »

I guess expression result in MC world is always string. I wonder if you can cast it to date there like: &datatype=[Date].

I'm trying to understand what you are trying to achieve here. If you elaborate it a little it might help suggest alternative routes to do the same. You could e.g. use after playback expression to set any fields when item has been played. But like said I don't really get what's your goal here. Where and how you use these fields?
Logged

rbmjr

  • World Citizen
  • ***
  • Posts: 112
Re: Library Field issue. Using an Expression changes the data type
« Reply #2 on: August 09, 2023, 07:30:09 pm »

Many people make playlists with specific songs and/or songs in a specific order. Having worked in IT for many years I wanted to create playlists not based upon specific songs, or songs in a specific order, rather dynamically create playlists based upon general criteria (Date Imported, Last Played, Never Played, Number Plays and Random) with the the number of songs from each decade being selected based upon values set in the Global Variables. Everything was working but I just didn't feel like I was getting the results that I had programmed for. So I set about creating ways to audit my creation. The way I was working on that led me to this post was to calculate the number of days that had elapsed since the song was last played. My assumption going in is that the Last Played date gets updated either before or after the song is played, so not knowing where this change occurs, I said let me make a copy of the Last Played date and then it doesn't matter when the Last Played date gets updated. In my original post I showed the way I was thinking this could be done, anyway I now know know that my logic was wrong yet it brings me to ask if there can be a "Before Playback" expression as well as an "After Playback" expression in the Library & Folders section. Anyway I have gone back and changed my SmartDate field to User and Date and set the SmartDate field using an expression column in a Smartlist playlist.
Logged

lepa

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 1978
Re: Library Field issue. Using an Expression changes the data type
« Reply #3 on: August 10, 2023, 04:57:30 am »

There is no "Before Playback Expression". One thing you could be interested is [Play History] user field where your append current time Now() to Play History after the playback. Then you can have all the dates when the item was played instead of just last played date.
e.g. like this
SetField(Play History,[Play History];Now())
Logged

rbmjr

  • World Citizen
  • ***
  • Posts: 112
Re: Library Field issue. Using an Expression changes the data type
« Reply #4 on: August 10, 2023, 09:54:51 am »

I'll check it out. Thanks
Logged
Pages: [1]   Go Up