Calculating an attribute to the number of days between two dates
There are two scripting languages for calculating values in ArcMap. You can use either VBScript or Python, and both are available through the Calculate Field tool.
To calculate the number of days between two dates with VBScript, follow these steps:
- Click the Editor menu on the Editor toolbar and click Start Editing.
- Click the List by Source button on the table of contents.
- Right-click the table or layer in the table of contents and choose Open Attribute Table.
Right-click the heading for the field to show the number of days between the date and the present date and click Field Calculator.
You can make calculations without being in an editing session; however, in that case, there is no way to undo the results.
In the field calculator text box, enter the following calculation VBScript expression:
DateDiff("d", [date_field], Now())Note:
In the code above, date_field should be changed to the name of your attribute table's date field name.
The number of days between the date in the date field and the current date are placed in the specified field.