How To: Copy dates stored in three number fields to one new date field
This article describes how to copy date information from multiple number fields to a single date field.
In the following example, the year, month, and day are in separate number fields; the final format will be YYYYMMDD.
- Open the table.
- Select Start Editing from the Table menu.
- Select Add Field from the Edit menu.
- In the Field Definition dialog box:
a. Set Name to an appropriate name, for example 'Date'.
b. Set Type to Date.
c. Click OK.
- Make the new date field active.
- Select Calculate from the Table menu.
- 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:
M the month as an integer from 1 to 12 MM same as 'M', two digits with leading zeros MMM the short form of the month name MMMM the long form of the month name d the day of the month as an integer from 1 to 31 dd same as 'd', two digits with leading zeros ddd the short form of the day name dddd the long form of the day name y the year without century yy same as 'y', two digits with leading zeros yyy the year with century, four digits with leading zeros yyyy same as 'yyy' yyyyy the year with century, not restricted to four digits c the century, without a leading zero cc the century, with a leading zero for single digit centuries w week of the year (Week 0 is first week with a Thursday) ww week of the year, two digits with leading zeros D numeric day of the week (Sunday = 1), one digit always AD AD or BC string depending upon the year CE CE or BCE string depending upon the year J Julian Day (days since January 1, 4713 BC) j day of the year jj day of the year, three digits with leading zeros
Last Published: 7/11/2016
Article ID: 000002464
Software: Legacy Products