HOW TO

Entfernen des Zeitstempels aus dem Datumsfeld in ArcGIS Pro

Last Published: October 17, 2024

Zusammenfassung

In certain cases, when loading new data, the date field is displayed in the format yyyy-mm-dd hh:mm:ss AM/PM. However, there may be instances where displaying the timestamp alongside the date is unnecessary. This article provides instructions to remove the timestamp from the date field in the attribute table in ArcGIS Pro.

Vorgehensweise

Use one of the methods below to remove the timestamp from the date fields in the attribute table in ArcGIS Pro.

Create a new Date Only field

Note:
This workflow is only applicable to ArcGIS Pro 3.2 and later.
  1. In ArcGIS Pro, open the attribute table of the layer.
  2. In the attribute table, click the Add button to add a new field.
  3. Fill in the new field name and alias for Field Name and Alias.
  4. Select Date Only for Data Type. Refer to ArcGIS Pro: Add Field (Data Management) for more information. Click Save.

The image of the new field with a Date Only field.

  1. In the attribute table, right-click the new field heading, and click Calculate Field.
  2. In the expression box, double-click the original date field under Fields.
  3. Click Apply > OK.

The image of the new field being calculated using the original date field.

Use the Field Calculator (Python) function

  1. In ArcGIS Pro, open the attribute table of the layer.
  2. In the attribute table, right-click the desired field heading, and click Calculate Field.
  3. In the Calculate Field window, select the feature layer for Input Table, the field name for Field Name (Existing or New), and Python for Expression Type.
  4. In the expression box, copy and paste the following script and replace FieldName accordingly.
FindDate(!FieldName!)
  1. In the Code Block box, copy and paste the following script:
def FindDate(date):
    if date is None:
        return None
    else:
        return str(date).split(" ").pop(0)
  1. Click Apply > OK.
The Calculate Field window with the Python scripting.
Note:
Alternatively, in the expression box, copy and paste the following script and replace FieldName accordingly.

timestamp(!FieldName!)

In the Code Block box, copy and paste the following script:

from datetime import datetime

def timestamp(mydate):
 date = mydate
 strdate = date.strftime("%Y/%m/%d")
 finaldate = datetime.strptime(strdate,"%Y/%m/%d")
 return finaldate

The following image shows the date field with only the date displayed in the attribute table.

The date field showing results of the timestamp removed.

Use the Convert Temporal Field tool

Note:
Using the Convert Temporal Field tool creates a new field in the attribute table.
  1. In ArcGIS Pro, on the Analysis tab, click Tools in the Geoprocessing group.
  2. In the Geoprocessing pane, search for and select Convert Temporal Field.
  3. In the Convert Temporal Field pane, in Parameters, select the input table or layer and input date field for the Input Table and Input Field boxes.
  4. In the Output Field Name box, fill in the output field name.
  5. In the Output Field Type box, select Date only to display the output date format selection.
Note:
If Text is selected, select the date format without the timestamp for Output Format.
  1. Click Run.
The Convert Time Field tool used to set the date format.

The following image shows the newly created date field with only the date displayed.

The newly created date field with the timestamp removed.

Artikel-ID: 000025447

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