Date field maths


(Matthew Harding) #1

Matrix Version: 5.5.7.1

I am implementing an asset review system where editors will set a date that an asset has been reviewed, and a review period (3, 6, 12 months).

Using these fields I would like to identify if an asset is due for review. I am looking at a third field, identifying if a review is upcoming or overdue.

I am looking at the conditions to trigger it and am just wondering if there is an easier way to do ‘date maths’?

Currently I modify the date to a unix time stamp (^date_format:U), multiplying the period by the number of seconds for a month (date.period x 2629743) and then seeing if this number is less than the Global date (in unix time stamp) (globals_date^date_format:U).

%asset_metadata_review.date^date_format:U^add:{asset_metadata_review.period^multiply:2629743}^lte:{globals_date^date_format:U}%

Is there a better way to handle ‘date maths’?

Is there a better way of doing the review dates?


(Lewis) #2

Hi @mharding,

If I’ve got the right end of the stick - you’re trying to set a date in the future (by some number of months) on which to review certain assets?

I think there may be several options in Squiz for this (if I’m understanding you right), including SOAP operations, Triggers or even using the native Workflow system.

Another way might be to use the Scheduled Jobs Manager with a Metadata Date field.

Squiz automatically performs certain tasks at regular intervals via the Scheduled Jobs Manager and one of these is to check Metadata Date fields across the system.

Assign a Metadata Date field to each asset you want to review and create a Metadata Time Trigger Action to email (for example) editors when the Trigger Condition says the date is in the past.

Each time the trigger fire, I believe you can set an action to advance the Metadata Date field by 3, 6 or 12 months each time. That way, the Scheduled Jobs Manager won’t execute the Trigger again until the next date.

Hope this helps. Bit tricky to explain all the pieces here :slight_smile: