HOW TO

Extract a portion of the Date field in ArcMap

Last Published: November 23, 2021

Summary

Individual portions in a Date field of a feature class or shapefile, such as year, month, day, hour, minute, or second, can be extracted using the DatePart() VB function in the Field Calculator.

Note:
Note that only the date portion (yyyy/mm/d) is supported in shapefile attributes, therefore, no time information (hh:mm:ss) can be extracted from a shapefile Date field.

Procedure

Note: 
Support for Visual Basic for Applications (VBA) for ArcMap and ArcCatalog ended with the ArcGIS 10.2.2 release, and Esri has not included VBA compatibility setups since version 10.5. Refer to ArcGIS Desktop and VBA Moving Forward for more information.
  1. Add a new field to the target feature class or shapefile. Specify the field type as Text. The Date field does not support a single date portion, so extract the portion to a Text field. Refer to ArcMap: Adding fields for instructions.
  2. Open the Field Calculator. Refer to ArcMap: Making field calculations for instructions.
  3. In the Field Calculator, copy and paste the following expression:
DatePart("PART", [DATEFIELD])
Note:
The PART argument can be one of the following keywords: yyyy (YEAR), m (MONTH), d (DAY), h (HOUR), n (MINUTE), or s (SECOND), and it must be enclosed with double quotation marks.
  1. Click OK to run the field calculation.
The Field Calculator with the expression to extract a minute part of the Date field

Article ID:000014933

Software:
  • ArcMap 10 6
  • ArcMap 10 x
  • ArcMap 10 7
  • ArcMap 10 8

Get help from ArcGIS experts

Contact technical support

Download the Esri Support App

Go to download options

Related Information

Discover more on this topic