AnsweredAssumed Answered

If Statements in Arcade

Question asked by c_signore on Jan 11, 2018
Latest reply on Jan 12, 2018 by khutchins-esristaff

I am working on a script currently in Arcade that is giving me some trouble, although it shouldn't seem like it would. I have a survey where field inspectors go in an log the date that a citation is issued. A person is charged $25 per day for the citation. However, that amount is halted when the inspector issues a completion date.  Therefore I have a conditional statement where, if the closed date is empty, then the person will continue to be charged the $25 on a daily basis until it is closed. If the closed date is filled in, the person will be charged the total from however many days it was from the day the citation started until it closed. Here is what I have right now: (I amusing the "Now" function because I am unsure of how to say if it is "Null" use this)

 

var open = Date($feature.DateofCitationTag);
var closed = Date($feature.CitationClosed);
var present = Today();
var closedDiff = DateDiff(closed, open, 'days');
var openDiff = DateDiff(present, open, 'days');
var closedAmount = 25 * closedDiff
var openAmount = 25 * openDiff
if (closed <= Now()) {
return "$" + closedAmount
}
else
return "$" + openAmount

 

The closedAmount shows up and is calculated correctly. However, the openAmount has been giving me a crazy value of $-438380.2083333 when the amount should be $200 (taking into consideration 8 days at $25 per day and counting). I am unsure of why it is acting this way. Anyone have any experience with a conditional statement like this? Thanks!

Outcomes