操作方法

如何在 ArcGIS Pro 中使用 Arcade 计算两个日期字段之间的差值

Last Published: July 21, 2023

摘要

Arcade is an expression language that can be used across the ArcGIS platform. The Arcade Date functions provide methods for creating and acquiring properties of date objects. For example, the DateAdd() and DateDiff() functions can be used to adjust the desired date based on a specified interval, and the Now() function to get the client current local time.

This article provides the steps to use Arcade in ArcGIS Pro to calculate the difference between two date fields using the DateDiff() function.

过程

  1. In ArcGIS Pro, open the attribute table containing the two date fields.
  2. Create a new integer field in the attribute table using the Add Field tool.
  3. In the attribute table, right-click the new field, and click Calculate Field to calculate the difference between the two date fields.
    1. In the Calculate Field pane, select the attribute table containing the date fields for Input Table.
    2. Ensure the new field is selected for Field Name.
    3. For Expression Type, select Arcade.
    4. In the expression text box, type the following expression to calculate the difference in minutes, and replace startDateField and endDateField with the respective field name.
var startDate = Date($feature.startDateField)
var endDate = Date($feature.endDateField)
var result = DateDiff(endDate, startDate, 'minutes')
return result
The image of Calculate Field pane.
Note:
To calculate the difference between the two date fields in other units, such as hours, seconds, or days, use the same expression and replace 'minute' to the desired unit.
  1. Click Run to apply the expression. The difference in minutes between the two date fields is calculated and populated in the new field.
The image of the calculated time difference.

文章 ID: 000023627

接收通知并查找新问题或常见问题的解决方案

从我们全新的 AI 聊天机器人中获得简明答案和视频解决方案。

下载 Esri 支持应用程序

相关信息

发现关于本主题的更多内容

获取来自 ArcGIS 专家的帮助

联系技术支持部门

下载 Esri 支持应用程序

转至下载选项