HOW TO

Remove the timestamp from the date field in ArcGIS Pro

Last Published: October 11, 2023

Summary

A shapefile stores dates in a date field with the yyyy-mm-dd format. A geodatabase formats the date as datetime yyyy-mm-dd hh:mm:ss AM or PM. ArcGIS Pro follows the Windows settings for date formats, and displays both the date and timestamps in the date fields. In some instances, the timestamp is not required to be displayed together with the date. This article provides instructions to remove the timestamp from the date fields in the attribute table in ArcGIS Pro.

Procedure

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

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 3 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 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 Time Field tool

Note:
Using the Convert Time 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 Time Field.
  3. In the Convert Time Field pane, in Parameters, select the input table and input time field for the Input Table and Input Time Field boxes.
  4. In the Input Time Format box, select the format that matches the format used in the table.
  5. In the Output Time Field box, fill in the field name.
  6. In the Output Time Type box, select Text to display the output time format selection.
  7. In the Output Time Format box, select the time format.
  8. 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.

Article ID:000025447

Software:
  • ArcGIS Pro 2 x
  • ArcGIS Pro 2 7 x

Get help from ArcGIS experts

Contact technical support

Download the Esri Support App

Go to download options

Related Information

Discover more on this topic