How to get Month in event_date variable

Hello,

I’m trying to get month part of event_date variable with ASSIN Program Rule Action Type. I did something like that :

d2:right(d2:left(V{event_date},5),2)

It’s work fine in web version but not in Android version. Surely because left and right must receive a string value.

Is there another way to retrieve month part of event_date ?

Regards

Hey @didate,
How are you? Yes, there are certains to follow for the android program rules. For example, IMPORTANT: REVIEW your Program Rules before updating to Android 2.2 in production

Therefore, let’s mention @dhis2-android team!

Hi @didate,
I’ve just tried it with the last android version (2.4.1) and it is working fine. This is the expression I’ve used:

d2:right(d2:left(V{current_date},7),2)

V{current_date} will return a date with the following format: yyyy-MM-dd. So the inner d2:left will return the first 7 characters from the left yyyy-MM and then the d2:right will return just MM which is what you are trying to achieve.

5 Likes

Thank you @Pablo it’s working on last android version 2.4.1.
I use the following expression because my dates are in french format (dd-MM-yyyy).

d2:right(d2:left(V{event_date},5),2)

Thank you so much.

2 Likes