Like other scripting languages, Arcade cannot be used to create stand-alone applications. Arcade differs from other scripting languages because it includes feature and geometry types. In the 1.11 release, geometries can be created and referenced. Field calculations, including areas, lengths, density, date/time, and some trigonometry functions, are available.
Date and Time in Microsoft Excel
In Microsoft Excel, dates and times have been managed as formatted numeric fields. A date/time value is represented as a double precision floating point serial number in which the integer portion is the number of days since December 31, 1899 (January 1, 1900, is value 1), and the decimal portion is the decimal fraction of a 24-hour day.
To calculate the decimal difference between two date/time values, simply subtract the older value from the more recent value to produce a value in decimal days. To convert to decimal minutes, the initial value is divided by 1,440, which is the number of minutes in a 24-hour day.
Date and Time in Arcade
In ArcGIS Pro, date/time formats are managed differently. Arcade is used to calculate the interval time. A multiline script with defined input and output parameters is used to calculate a time interval. Arcade includes several date/time functions, such as DateAdd(), DateDiff(), and Now().
Interval Time Calculation
In “Measuring Firefighter Performance with ArcGIS Pro,” the Arcade script in Listing 1 was used to calculate the difference between when an apparatus left the station and when it arrived at the site of the emergency to evaluate performance. That script is shown with code comments (denoted by //) explaining what each line of code does. Since Arcade calculates interval time as an integer value, it is important to first calculate the result in seconds, and then divide by 60 (the number of seconds in a minute). This procedure is not as precise as calculating actual decimal minutes, but it is sufficiently precise for emergency response modeling.
var Enroute = Date($feature.EnrouteDT_T2)
//Defines a variable named Enroute and sets its source to EnrouteDT_T2
var Arrival = Date($feature.ArrivalDT_T3)
//Defines a variable named Arrival and sets its source to ArrivalDT_T3
var result = DateDiff(Arrival, Enroute, 'seconds')
//Defines a variable named result, calls the DateDiff function between variables Arrival and Enroute, and returns an integer value in seconds
var Minutes = (result/ 60)
//Defines a Minutes variable and calculates it as result / 60
//Returns the Minutes values inti field as T3-T2