CÓMO

Calcular la diferencia entre dos campos de fecha utilizando Arcade en ArcGIS Pro

Last Published: July 21, 2023

Resumen

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.

Procedimiento

  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. de artículo: 000023627

Recibir notificaciones y encontrar soluciones a problemas nuevos o comunes

Obtenga respuestas resumidas y soluciones de vídeo de nuestro nuevo chatbot de IA.

Descargar la aplicación de soporte de Esri

Información relacionada

Descubrir más sobre este tema

Obtener ayuda de expertos en ArcGIS

Contactar con el soporte técnico

Descargar la aplicación de soporte de Esri

Ir a opciones de descarga