Calculating minutes between two dates

Hey @rose indeed there’s a problem with this function in 2.30 and I would say beyond that: [DHIS2-6038] - Jira

We had the same problem for a programRUle that assigned a value to a DE. I don’t know if what I am about to write can also work in programIndicators. The workaround we did was not really straightforward but working for us (although we have now problems updated 2.33)

We created a custom javascript function like the one below and incorporate its definition in the scripts.js

function difference_time_minutes(date1, date2) {
start_actual_time = new Date(date1).getTime();
end_actual_time = new Date(date2).getTime();
//alert( date1);
//alert(date2);
var diff = end_actual_time - start_actual_time;

var diffSeconds = diff / 1000;

var MM = (diffSeconds) / 60;

//alert(MM);
return MM;}

However this is no longer recognized in the new capture app. We are trying to use again the d2:minutesbetween function in 2.33 but still facing the same challenges. Hope that anyone can advice us better.

Thanks