How To: Extract a portion of the Date field
Individual portions in a Date field of a feature class or shapefile, such as year, month, day, hour, minute, or second, can 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.
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. See: ArcGIS Desktop and VBA Moving Forward
- 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 the portion should be extracted to a Text field. See: Adding fields instructions
- Open the Field Calculator for the new field following steps in this help page: Making simple field calculations
- In the Field Calculator, enter:
DatePart("PART", [DATEFIELD])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.
- Click OK to run the field calculation.
Last Published: 9/16/2019
Article ID: 000014933
Software: ArcMap 10.4.1, 10.4, 10.3.1, 10.3, 10.2.2, 10.2.1, 10.2, 10.1, 10