ArcGIS Desktop

  • Documentation
  • Support

  • My Profile
  • Help
  • Sign Out
ArcGIS Desktop

ArcGIS Online

The mapping platform for your organization

ArcGIS Desktop

A complete professional GIS

ArcGIS Enterprise

GIS in your enterprise

ArcGIS for Developers

Tools to build location-aware apps

ArcGIS Solutions

Free template maps and apps for your industry

ArcGIS Marketplace

Get apps and data for your organization

  • Documentation
  • Support
Esri
  • Sign In
user
  • My Profile
  • Sign Out

Help

  • Home
  • Get Started
  • Map
  • Analyze
  • Manage Data
  • Tools
  • More...

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:

  1. Click the Editor menu on the Editor toolbar and click Start Editing.
  2. Click the List by Source button on the table of contents.
  3. Right-click the table or layer in the table of contents and choose Open Attribute Table.
  4. 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.

  5. 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.

  6. Click OK.

    The number of days between the date in the date field and the current date are placed in the specified field.

Tip:
Valid dates range from January 1, 0100, to December 31, 9999. Keep in mind that date calculations using and producing date values earlier than the year in which the Gregorian calendar was adopted may not be appropriate.

Related topics

  • Fundamentals of field calculations

ArcGIS Desktop

  • Home
  • Documentation
  • Support

ArcGIS Platform

  • ArcGIS Online
  • ArcGIS Desktop
  • ArcGIS Enterprise
  • ArcGIS for Developers
  • ArcGIS Solutions
  • ArcGIS Marketplace

About Esri

  • About Us
  • Careers
  • Esri Blog
  • User Conference
  • Developer Summit
Esri
Tell us what you think.
Copyright © 2018 Esri. | Privacy | Legal