I am creating a Dashboard displaying data from my city's permits. I have text fields of the application date and the issued date. I am trying to cast them into date fields and then get the average days that it took to issue the permit. When I run the script that I have so far, I get an error: Test execution error: Execution error - Invalid parameter. Verify test data.
Here is the script I have so far:
var fs = FeatureSetByPortalItem(portal_,
'Item ID', 0,['*'], false);
for (var f in fs) {
var date_Applied = f["Applied_Date"];
var date_Issued = f['Issued_Date'];
var startDate = DateOnly(date_Applied);
var endDate = DateOnly(date_Issued);
var differences = DateDiff(startDate, endDate, 'days');
var total = Sum(differences);
var totalrows = Count(differences);
var avg = total/totalrows;}
return avg
Any help is greatly appreciated.