{"id":386671,"date":"2020-12-02T22:10:58","date_gmt":"2020-12-03T06:10:58","guid":{"rendered":"https:\/\/www.esri.com\/about\/newsroom\/?post_type=arcuser&#038;p=386671"},"modified":"2020-12-02T22:10:58","modified_gmt":"2020-12-03T06:10:58","slug":"scripting-time-calculations-in-arcgis-arcade","status":"publish","type":"arcuser","link":"https:\/\/www.esri.com\/about\/newsroom\/arcuser\/scripting-time-calculations-in-arcgis-arcade","title":{"rendered":"Scripting Time Calculations in ArcGIS Arcade"},"author":1031,"featured_media":0,"menu_order":0,"template":"","format":"standard","meta":{"_acf_changed":false,"sync_status":"","episode_type":"","audio_file":"","podmotor_file_id":"","podmotor_episode_id":"","castos_file_data":"","cover_image":"","cover_image_id":"","duration":"","filesize":"","filesize_raw":"","date_recorded":"","explicit":"","block":"","itunes_episode_number":"","itunes_title":"","itunes_season_number":"","itunes_episode_type":"","_links_to":"","_links_to_target":""},"categories":[10532,10412,25022],"tags":[472461,317472,201052,276772],"arcuser_issues":[472351],"class_list":["post-386671","arcuser","type-arcuser","status-publish","format-standard","hentry","category-arcgis-arcade","category-arcgis-pro","category-hands-on","tag-arcuser","tag-mike-price","tag-python","tag-time","arcuser_issues-arcuser-fall-2020"],"acf":{"short_description":"Learn how to use ArcGIS Arcade to perform time calculations in ArcGIS Pro. ","pdf":{"host_remotely":false,"file":386691,"file_url":""},"flexible_content":[{"acf_fc_layout":"blockquote","content":"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."},{"acf_fc_layout":"content","content":"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.\r\n<h3>Date and Time in Microsoft Excel<\/h3>\r\nIn 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.\r\nTo 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.\r\n<h3>Date and Time in Arcade<\/h3>\r\nIn 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().\r\n<h3>Interval Time Calculation<\/h3>\r\nIn \u201cMeasuring Firefighter Performance with ArcGIS Pro,\u201d 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."},{"acf_fc_layout":"content","content":"<pre><code><span style=\"color: #008080;\">var<\/span> Enroute = Date($feature.EnrouteDT_T2)\r\n\r\n<span style=\"color: #0c7825;\">\/\/Defines a variable named Enroute and sets its source to EnrouteDT_T2<\/span>\r\n<span style=\"color: #008080;\">var<\/span> Arrival = Date($feature.ArrivalDT_T3)\r\n\r\n<span style=\"color: #0c7825;\">\/\/Defines a variable named Arrival and sets its source to ArrivalDT_T3<\/span>\r\n\r\n<span style=\"color: #008080;\">var<\/span> result = DateDiff(Arrival, Enroute, <span style=\"color: #d14;\">'seconds'<\/span>)\r\n\r\n<span style=\"color: #0c7825;\">\/\/Defines a variable named result, calls the DateDiff function between variables Arrival and Enroute, and returns an integer value in seconds<\/span>\r\n\r\n<span style=\"color: #008080;\">var<\/span> Minutes = (result\/ <span style=\"color: #d14;\">60<\/span>)\r\n\r\n<span style=\"color: #0c7825;\">\/\/Defines a Minutes variable and calculates it as result \/ 60<\/span>\r\n\r\n<span style=\"color: #008080;\">return<\/span> Minutes\r\n\r\n<span style=\"color: #0c7825;\">\/\/Returns the Minutes values inti field as T3-T2<\/span><\/code><\/pre>"}],"references":null},"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v25.9 (Yoast SEO v25.9) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Scripting Time Calculations in ArcGIS Arcade<\/title>\n<meta name=\"description\" content=\"Learn how to use ArcGIS Arcade to perform time calculations in ArcGIS Pro. ArcGIS Arcade is a simple, portable scripting language used across the ArcGIS platformthat supports building custom visualizations, labeling expressions, pop-ups and certain field calculations.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.esri.com\/about\/newsroom\/arcuser\/scripting-time-calculations-in-arcgis-arcade\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Scripting Time Calculations in ArcGIS Arcade\" \/>\n<meta property=\"og:description\" content=\"Learn how to use ArcGIS Arcade to perform time calculations in ArcGIS Pro. ArcGIS Arcade is a simple, portable scripting language used across the ArcGIS platformthat supports building custom visualizations, labeling expressions, pop-ups and certain field calculations.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.esri.com\/about\/newsroom\/arcuser\/scripting-time-calculations-in-arcgis-arcade\" \/>\n<meta property=\"og:site_name\" content=\"Esri\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/esrigis\/\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.esri.com\/about\/newsroom\/app\/uploads\/2020\/11\/saferscripting_banner.jpg\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:site\" content=\"@Esri\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\n\t    \"@context\": \"https:\/\/schema.org\",\n\t    \"@graph\": [\n\t        {\n\t            \"@type\": \"WebPage\",\n\t            \"@id\": \"https:\/\/www.esri.com\/about\/newsroom\/arcuser\/scripting-time-calculations-in-arcgis-arcade\",\n\t            \"url\": \"https:\/\/www.esri.com\/about\/newsroom\/arcuser\/scripting-time-calculations-in-arcgis-arcade\",\n\t            \"name\": \"Scripting Time Calculations in ArcGIS Arcade\",\n\t            \"isPartOf\": {\n\t                \"@id\": \"https:\/\/www.esri.com\/about\/newsroom\/#website\"\n\t            },\n\t            \"datePublished\": \"2020-12-03T06:10:58+00:00\",\n\t            \"description\": \"Learn how to use ArcGIS Arcade to perform time calculations in ArcGIS Pro. ArcGIS Arcade is a simple, portable scripting language used across the ArcGIS platformthat supports building custom visualizations, labeling expressions, pop-ups and certain field calculations.\",\n\t            \"breadcrumb\": {\n\t                \"@id\": \"https:\/\/www.esri.com\/about\/newsroom\/arcuser\/scripting-time-calculations-in-arcgis-arcade#breadcrumb\"\n\t            },\n\t            \"inLanguage\": \"en-US\",\n\t            \"potentialAction\": [\n\t                {\n\t                    \"@type\": \"ReadAction\",\n\t                    \"target\": [\n\t                        \"https:\/\/www.esri.com\/about\/newsroom\/arcuser\/scripting-time-calculations-in-arcgis-arcade\"\n\t                    ]\n\t                }\n\t            ]\n\t        },\n\t        {\n\t            \"@type\": \"BreadcrumbList\",\n\t            \"@id\": \"https:\/\/www.esri.com\/about\/newsroom\/arcuser\/scripting-time-calculations-in-arcgis-arcade#breadcrumb\",\n\t            \"itemListElement\": [\n\t                {\n\t                    \"@type\": \"ListItem\",\n\t                    \"position\": 1,\n\t                    \"name\": \"Home\",\n\t                    \"item\": \"https:\/\/www.esri.com\/about\/newsroom\"\n\t                },\n\t                {\n\t                    \"@type\": \"ListItem\",\n\t                    \"position\": 2,\n\t                    \"name\": \"Scripting Time Calculations in ArcGIS Arcade\"\n\t                }\n\t            ]\n\t        },\n\t        {\n\t            \"@type\": \"WebSite\",\n\t            \"@id\": \"https:\/\/www.esri.com\/about\/newsroom\/#website\",\n\t            \"url\": \"https:\/\/www.esri.com\/about\/newsroom\/\",\n\t            \"name\": \"Esri\",\n\t            \"description\": \"Esri Newsroom\",\n\t            \"potentialAction\": [\n\t                {\n\t                    \"@type\": \"SearchAction\",\n\t                    \"target\": {\n\t                        \"@type\": \"EntryPoint\",\n\t                        \"urlTemplate\": \"https:\/\/www.esri.com\/about\/newsroom\/?s={search_term_string}\"\n\t                    },\n\t                    \"query-input\": {\n\t                        \"@type\": \"PropertyValueSpecification\",\n\t                        \"valueRequired\": true,\n\t                        \"valueName\": \"search_term_string\"\n\t                    }\n\t                }\n\t            ],\n\t            \"inLanguage\": \"en-US\"\n\t        },\n\t        {\n\t            \"@type\": \"Person\",\n\t            \"@id\": \"https:\/\/www.esri.com\/about\/newsroom\/#\/schema\/person\/82e5143bcdebadf8fd64d84e503ca468\",\n\t            \"name\": \"Monica Pratt\",\n\t            \"image\": {\n\t                \"@type\": \"ImageObject\",\n\t                \"inLanguage\": \"en-US\",\n\t                \"@id\": \"https:\/\/www.esri.com\/about\/newsroom\/#\/schema\/person\/image\/\",\n\t                \"url\": \"https:\/\/www.esri.com\/about\/newsroom\/app\/uploads\/2018\/08\/MonicaMug_agol2.jpg\",\n\t                \"contentUrl\": \"https:\/\/www.esri.com\/about\/newsroom\/app\/uploads\/2018\/08\/MonicaMug_agol2.jpg\",\n\t                \"caption\": \"Monica Pratt\"\n\t            },\n\t            \"description\": \"Monica Pratt is the founding and current editor of ArcUser magazine, the executive editor of ArcNews magazine, the editor of Esri Globe and head of the Publications team at Esri. She has been writing on technology topics, specializing in GIS, for more than 30 years. Before joining Esri in 1997, she worked for newspapers and in the financial industry.\",\n\t            \"sameAs\": [\n\t                \"https:\/\/x.com\/ArcUser\"\n\t            ],\n\t            \"url\": \"\"\n\t        }\n\t    ]\n\t}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Scripting Time Calculations in ArcGIS Arcade","description":"Learn how to use ArcGIS Arcade to perform time calculations in ArcGIS Pro. ArcGIS Arcade is a simple, portable scripting language used across the ArcGIS platformthat supports building custom visualizations, labeling expressions, pop-ups and certain field calculations.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.esri.com\/about\/newsroom\/arcuser\/scripting-time-calculations-in-arcgis-arcade","og_locale":"en_US","og_type":"article","og_title":"Scripting Time Calculations in ArcGIS Arcade","og_description":"Learn how to use ArcGIS Arcade to perform time calculations in ArcGIS Pro. ArcGIS Arcade is a simple, portable scripting language used across the ArcGIS platformthat supports building custom visualizations, labeling expressions, pop-ups and certain field calculations.","og_url":"https:\/\/www.esri.com\/about\/newsroom\/arcuser\/scripting-time-calculations-in-arcgis-arcade","og_site_name":"Esri","article_publisher":"https:\/\/www.facebook.com\/esrigis\/","og_image":[{"url":"https:\/\/www.esri.com\/about\/newsroom\/app\/uploads\/2020\/11\/saferscripting_banner.jpg","type":"","width":"","height":""}],"twitter_card":"summary_large_image","twitter_site":"@Esri","schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.esri.com\/about\/newsroom\/arcuser\/scripting-time-calculations-in-arcgis-arcade","url":"https:\/\/www.esri.com\/about\/newsroom\/arcuser\/scripting-time-calculations-in-arcgis-arcade","name":"Scripting Time Calculations in ArcGIS Arcade","isPartOf":{"@id":"https:\/\/www.esri.com\/about\/newsroom\/#website"},"datePublished":"2020-12-03T06:10:58+00:00","description":"Learn how to use ArcGIS Arcade to perform time calculations in ArcGIS Pro. ArcGIS Arcade is a simple, portable scripting language used across the ArcGIS platformthat supports building custom visualizations, labeling expressions, pop-ups and certain field calculations.","breadcrumb":{"@id":"https:\/\/www.esri.com\/about\/newsroom\/arcuser\/scripting-time-calculations-in-arcgis-arcade#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.esri.com\/about\/newsroom\/arcuser\/scripting-time-calculations-in-arcgis-arcade"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.esri.com\/about\/newsroom\/arcuser\/scripting-time-calculations-in-arcgis-arcade#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.esri.com\/about\/newsroom"},{"@type":"ListItem","position":2,"name":"Scripting Time Calculations in ArcGIS Arcade"}]},{"@type":"WebSite","@id":"https:\/\/www.esri.com\/about\/newsroom\/#website","url":"https:\/\/www.esri.com\/about\/newsroom\/","name":"Esri","description":"Esri Newsroom","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.esri.com\/about\/newsroom\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.esri.com\/about\/newsroom\/#\/schema\/person\/82e5143bcdebadf8fd64d84e503ca468","name":"Monica Pratt","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.esri.com\/about\/newsroom\/#\/schema\/person\/image\/","url":"https:\/\/www.esri.com\/about\/newsroom\/app\/uploads\/2018\/08\/MonicaMug_agol2.jpg","contentUrl":"https:\/\/www.esri.com\/about\/newsroom\/app\/uploads\/2018\/08\/MonicaMug_agol2.jpg","caption":"Monica Pratt"},"description":"Monica Pratt is the founding and current editor of ArcUser magazine, the executive editor of ArcNews magazine, the editor of Esri Globe and head of the Publications team at Esri. She has been writing on technology topics, specializing in GIS, for more than 30 years. Before joining Esri in 1997, she worked for newspapers and in the financial industry.","sameAs":["https:\/\/x.com\/ArcUser"],"url":""}]}},"sort_order":"14","_links":{"self":[{"href":"https:\/\/www.esri.com\/about\/newsroom\/wp-json\/wp\/v2\/arcuser\/386671","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.esri.com\/about\/newsroom\/wp-json\/wp\/v2\/arcuser"}],"about":[{"href":"https:\/\/www.esri.com\/about\/newsroom\/wp-json\/wp\/v2\/types\/arcuser"}],"author":[{"embeddable":true,"href":"https:\/\/www.esri.com\/about\/newsroom\/wp-json\/wp\/v2\/users\/1031"}],"version-history":[{"count":0,"href":"https:\/\/www.esri.com\/about\/newsroom\/wp-json\/wp\/v2\/arcuser\/386671\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.esri.com\/about\/newsroom\/wp-json\/wp\/v2\/media?parent=386671"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.esri.com\/about\/newsroom\/wp-json\/wp\/v2\/categories?post=386671"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.esri.com\/about\/newsroom\/wp-json\/wp\/v2\/tags?post=386671"},{"taxonomy":"arcuser_issues","embeddable":true,"href":"https:\/\/www.esri.com\/about\/newsroom\/wp-json\/wp\/v2\/arcuser_issues?post=386671"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}