HOW TO

Konvertieren einer Dezimalzeit in eine Dauer von Stunden, Minuten und Sekunden

Last Published: August 24, 2023

Zusammenfassung

In ArcGIS Pro, decimal time can be converted to hours, minutes, and seconds using the Convert Time Field tool and the Calculate Field tool. However, in some instances, the result of the Convert Time Field tool represents a point of time and is stored in a date field as datetime yyyy-mm-dd hh:mm:ss AM or PM. This article provides the workflow to convert decimal time to a duration of time represented in hours, minutes, and seconds using the Calculate Field tool. The result of this workflow is stored in a text field.

Vorgehensweise

  1. In ArcGIS Pro, in the Contents pane, right-click the layer containing the decimal time, and select Attribute Table.
  2. In the table view pane, right-click the decimal time field, and select Calculate Field. In this example, the field is DecimalTime.
Open the Calculate Field window by right-clicking the header of the decimal time field, and select Calculate Field from the list.
  1. In the Calculate Field window, for Field Name, click the drop-down arrow to select an existing field, or type a new name to populate the calculation output in a new field. In this example, the name of the new field is Hms.
  2. In the expression box, type the code provided below. Replace 'Field Name' with the name of the decimal time field.
str(int(!Field Name!))+"h "+str(round((!Field Name!*60) % 60))+"m "+str(round((!Field Name!*3600)% 60))+"s"
Note:
Do not remove the exclamation marks surrounding the field name. Custom texts or spacing can be replaced in the double quotation marks (" ") if required.
  1. Click Apply.
  2. Click OK to close the Calculate Field window.
To perform the calculation, in the Calculate Field window, type a name in the Field Name section to create a new field for the output or click the drop-down arrow to select an existing field (Step 3). Copy and paste the expression in the box (Step 4). At the bottom of the window, click the Apply button on the left to run the calculation (Step 5). Click the OK button on the right to close the window (Step 6).

The output is populated in the new text field in a custom format of hours, minutes, and seconds.

In the table view pane, the output of the calculation is populated in the new field Hms, the duration of time is displayed in the custom format of h, m, and s.

Artikel-ID: 000026666

Benachrichtigungen erhalten und Lösungen für neue oder häufige Probleme finden

Unser neuer KI-Chatbot stellt zusammengefasste Antworten und Videolösungen für Sie bereit.

Esri Support App herunterladen

Zugehörige Informationen

Weitere Informationen zu diesem Thema erkunden

Unterstützung durch ArcGIS-Experten anfordern

An den technischen Support wenden

Esri Support App herunterladen

Zu Download-Optionen wechseln