Calculating date within range


(Mahearnpad) #1

Matrix Version: 5.3.2

I have 3 metadata fields:

  1. converts an existing date field into a whole number (unix epoch)
  2. stores the number of seconds 3 months before today (as a whole number)
  3. stores either “NEW” or “OLD”, depending on whether the value of the first field is within the range defined in 2.

The code for each of these is:

1.  EffectiveDate_number: %metadata_field_EffectiveDate^date_format:U%

2.  EffectiveDate_past_limit: %globals_date_U^subtract:7890000%

3.  EffectiveDate_difference: %metadata_field_EffectiveDate_number^lt_date:{metadata_field_EffectiveDate_past_limit}:OLD:NEW%

However, it’s not working 3 returns a false value each time.

Where am I going wrong?

TIA


(Bart Banda) #2

I don’t think you can do that yet with the %metadata_field% keyword, as in, use keyword replacements inside its keyword modifiers.

Also, because you are on 5.3.2, you would need to use the ^replace_keywords: format first, ie:

%metadata_field_EffectiveDate_number^replace_keywords:lt_date:{metadata_field_EffectiveDate_past_limit}:OLD:NEW%

Do you need to store this in a metadata field? Or can you do this logic in the context of where you are needing to print it? In a Paint Layout or something?


(Mahearnpad) #3

That’s not what I wanted to hear! :wink:

I’ll give the paint layout solution a go. Can I use logic directly in the page now (I read somewhere in the manual that conditional logic can be used in a container now)?

thanks


(Bart Banda) #4

Yep, you have been able to do this for a long time. :slight_smile: