English

How To: Copy dates stored in three number fields to one new date field

Summary

This article describes how to copy date information from multiple number fields to a single date field.

Procedure

In the following example, the year, month, and day are in separate number fields; the final format will be YYYYMMDD.

  1. Open the table.
  2. Select Start Editing from the Table menu.
  3. Select Add Field from the Edit menu.
  4. In the Field Definition dialog box:
    a. Set Name to an appropriate name, for example 'Date'.
    b. Set Type to Date.
    c. Click OK.
  5. Make the new date field active.
  6. Select Calculate from the Table menu.
  7. Type the following in the expression text box of the Field Calculator dialog box.
    Code:
    Date.make([Year].asstring+":"+[Month].asstring+":"+[Day].asstring,"yyyy:M:dd")
    Where, Year, Month and Day are the names of the numeric fields that contain the appropriate information.
    Note:
    ArcView uses date format characters to identify date and time components. 
    
    You format dates by specifying how the year, month, and day appear. A date value plug is one of the following:
    Mthe month as an integer from 1 to 12
    MMsame as 'M', two digits with leading zeros
    MMMthe short form of the month name
    MMMMthe long form of the month name
    dthe day of the month as an integer from 1 to 31
    ddsame as 'd', two digits with leading zeros
    dddthe short form of the day name
    ddddthe long form of the day name
    ythe year without century
    yysame as 'y', two digits with leading zeros
    yyythe year with century, four digits with leading zeros
    yyyysame as 'yyy'
    yyyyythe year with century, not restricted to four digits
    cthe century, without a leading zero
    ccthe century, with a leading zero for single digit centuries
    wweek of the year (Week 0 is first week with a Thursday)
    wwweek of the year, two digits with leading zeros
    Dnumeric day of the week (Sunday = 1), one digit always
    ADAD or BC string depending upon the year
    CECE or BCE string depending upon the year
    JJulian Day (days since January 1, 4713 BC)
    jday of the year
    jjday of the year, three digits with leading zeros