Skip To Content

Date fields

Whether you're displaying, calculating, or selecting date attributes, you must determine the appropriate way to work with date fields in your database.

Selecting and displaying date field values using the Select Layer By Attribute tool and similar query-building dialog boxes is done using a SQL syntax. The SQL syntax used to select and display date field values varies based on the type of database of data. This is described in detail in the SQL reference topic.

Calculating and displaying date fields in the attribute table is done in a different format and syntax. This is because the field calculator in ArcGIS Pro uses Python functions and the display format depends on your regional settings, rather than the underlying database's format on the system.

Displaying dates

A shapefile stores dates in a date field with this format: yyyy-mm-dd. A geodatabase formats the date as datetime yyyy-mm-dd hh:mm:ss AM or PM. Settings on your Windows system determine how the dates display in ArcGIS Pro—M/d/yy, MM/dd/yy, yy/MM/dd, and so on. ArcGIS Pro uses the system short date format (numerical) to display dates.

ArcGIS Pro follows the Windows settings for date formats.

Calculating date fields

When calculating date fields, the field calculator uses Python datetime functions. Some of the functions support datetime yyyy-mm-dd hh:mm:ss AM or PM. However, for shapefiles, the time portion is truncated from the datetime value. For example, the datetime 2002-08-20 12:00:00 PM is stored in a shapefile as 2002-08-20.

Any Python datetime function can be used to calculate a date. If you want to calculate an attribute equal to the current time, use the today() function.

You can also use two digits for the year value when calculating dates. When you calculate a date such as date_field = dateserial(02,8,20) and specify two digits for the year (02 in this case), your system's settings control which century is used. These settings can be adjusted through the region and time options in Windows.

Select features using a date field

An SQL selection query can be built for date fields, numeric fields, and string fields using the Select Layer By Attribute geoprocessing tool. You can select individual or multiple records by querying a dataset based on a date value. A data-dependent syntax is required for querying dates.

Refer to the SQL reference guide for a description of the different syntax and the specifications of querying dates.