Matrix Version: v126.96.36.199
I’m trying to find a way to get the difference between 2 dates into a metadata field and sort an asset listing by it but even though I can get the correct result the asset list won’t sort it correctly.
The reason for this functionality is to list Event assets and News assets in the same asset listing and sort them by the difference in time between now and when the news item was published or the start date of the event. ie. show the item dated closest to right now regardless of asset type.
I know I could just have a metadata field and manually update it each time a new asset is created but I’d prefer to automate the process by pulling in the required date using keywords.
I have a simplified test setup with assets as below. Dates are in the metadata field config.date_diff. Asset list is set to sort on this field in ascending order (‘closest to now’ to ‘furthest from now’).
When the config.date_diff metadata field is just:
The result is as expected (News 1: 50258682, News 2: 18636256, News 3: 56672) and the asset list sorts as expected (News 3, News 2, News 1).
But as soon as I try to add any conditionals so that News assets and Event assets use different date sources I get unexpected results. Sometimes the values seem correct but the sort still isn’t correct and other times the values returned are just whacky.
This is ideally where I want to end up with the Metadata field:
Note: the only difference is the value I pull the date from.
Any thoughts on this or other possible approaches?