Calculate the number of days between two dates

Say you have a Due Date field on a form, and you want to show how many days are left until that Due Date arrives. A quick way to do this is to add a new text box to the form, and then use the DateDiff function in that text box to do the calculation. (For more about forms, see Create an Access form.)

Note:  This article doesn’t apply to Access apps – the new kind of database you design with Access and publish online. See Create an Access app for more information.

  1. Right-click the form in the Navigation Pane and then click Layout View.

  2. Click Design > Text Box, hold down the Ctrl key, and then click on the layout where you want to put the text box.

  3. Click the new text box, and press F4 to display the Property Sheet if it's not already displayed.

  4. On the Data tab of the Property Sheet, in the Control Source property box, type the following:


Your form should look something like this:

Entering the DateDiff function in the Control Source property of a text box.

The expression in this example subtracts today’s date (Date()) from the Due Date. The "d" tells Access to calculate the number of days (as opposed to years, months, etc.). If your text box is named something other than DueDate, substitute your actual text box name in the function arguments.

More information

Learn more about expressions by reading Build an expression and Add functions to Access expressions.

For more about forms, see Create an Access form.

Expand your skills
Explore training
Get new features first
Join Office Insiders

Was this information helpful?

Thank you for your feedback!

Thank you for your feedback! It sounds like it might be helpful to connect you to one of our Office support agents.