English

How To: Extract a portion of the Date field

Summary

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.

Procedure

  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 the portion should be extracted to a Text field. See: Adding fields instructions
  2. Open the Field Calculator for the new field following steps in this help page: Making simple field calculations
  3. 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.
  4. Click OK to run the field calculation. 

    User-added image

Related Information