Deprecated: Function get_currentuserinfo is deprecated since version 4.5.0! Use wp_get_current_user() instead. in /data/wordpress/about/newsroom/wp-includes/functions.php on line 6078

Warning: Undefined array key 0 in /data/wordpress/about/newsroom/wp-content/uploads/plugins/adobe-dtm/dtm.php on line 126
Scripting Time Calculations in ArcGIS Arcade
arcuser

Scripting Time Calculations in ArcGIS Arcade

ArcGIS Arcade is a simple, portable scripting language used across the ArcGIS platform. It is included in ArcGIS Pro, ArcGIS Enterprise, the ArcGIS API for JavaScript, and the ArcGIS Runtime SDKs. Arcade supports building custom visualizations, labeling expressions, pop-ups and certain field calculations.

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

return Minutes

//Returns the Minutes values inti field as T3-T2

About the author

Mike Price is the president of Entrada/San Juan Inc. and was the mining and earth sciences industry manager at Esri between 1997 and 2002. He has been writing tutorials that help ArcUser readers understand and use GIS more intelligently since the magazine's founding. He is geologist and has been a volunteer fire fighter in Moab, Utah for many years.


Warning: Undefined array key "issue_pdf" in /data/wordpress/about/newsroom/wp-content/themes/esri_newsroom/fed_components/gateway/news/issue-bar.php on line 24

Warning: Trying to access array offset on value of type null in /data/wordpress/about/newsroom/wp-content/themes/esri_newsroom/fed_components/gateway/news/issue-bar.php on line 24