Trigger program rule for only TEIs registered on or after a specific static date

Dear Collegues,

I am trying to validate a field (a registration number) using a regular expression for TEIs enrolled in a given programme on or after a specific date i.e. I will not do this for those registered on or after a given period (as there’s so much back log to deal with, including correction of paper-based records if i attempt to apply the validation on all TEIs - previous and new). The program rules works fine without date condition in the program rule expression;

d2:hasValue('someID') && !d2:validatePattern(A{SomeID},'[0-9]{3}[A-Z]{3}[0-9]{2}')

However, if I and the enrolment date to have this applied to only newly registered TEIs on or after 1st Nov 2019, it fails. See below;

d2:hasValue('someID') && !d2:validatePattern(A{someID},'[0-9]{3}[A-Z]{3}[0-9]{2}') && V{enrollment_date} >= '2019-11-01'

I’ve been scratching my head around and wondering what wrong am doing.

I’m probably missing something…

1 Like

Hi @paleu256,

I think the >= operator does not work with dates, just with numbers. You could try something like:
d2:daysBetween( V{enrollment_date}, '2019-11-01') <= 0
This will evaluate to true if the enrollment date is after or equeals the selected one.

3 Likes

I have gained sth from this conversation.

2 Likes

very helpful one thing I also discovered is to use instance/server specific date settings in my case the static date format had to change to ‘DD-MM-YYYY’ rather than ‘YYYY-MM-DD’ for daysBetween function to return expected results. Problem solved. Many thanks!! @Pablo

2 Likes