SET UP A TEXT BOX TO DISPLAY THE DIFFERENCE BETWEEN TWO DATES (DISPLAY VALUE OF 1 IF DATES ARE THE SAME)

This MSAccess tutorial explains how to set up a text box to display the difference between two dates in Access 2007 (with screenshots and step-by-step instructions).

See solution in other versions:

Question: In an Access 2007 Form or Report, I’d like to calculate/display the difference between 2 date fields (From_Date and To_Date). I want to display the number of days between ‘From_Date’ and ‘To_Date’, and if the dates are the same date, I’d like to display the result as 1.

Answer: You can create a Text Box on your Form or Report. Then set the Control Source property of the Text Box to the following formula:

=IIf([From_Date]=[To_Date],1,DateDiff("d",[From_Date],[To_Date]))

Microsoft Access

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s