graphic2
graphic1

Exam 77-424: Microsoft Access 2013
3.0 Create Queries
3.3 Utilize Calculated Fields and Grouping Within a Query: Use Comparison Operators (DateDiff)

Calculate the Date Difference

Many businesses need to calculate the difference between two dates. Microsoft Access

uses a DateDiff() function. It goes like this:

 

DaysRented: DateDiff("d",[DateRented],Now ())

 

Where DaysRented is the Alias,

DateDiff() is the function,

"d" is the time interval,

[DateRented] is a field in tblMovieRented.

 

Other DateDiff intervals are:

Month

"m"

Year

"yyyy"

Week

"ww"

Hour

"h"

Minutes

"n"

 

4. Try it: Create a Calculated Field

Click on a blank Field in the QBE Grid.

Right click to Zoom. Enter the Expression:

 

DaysRented: DateDiff("d",[DateRented],Now ())
 

Click OK. Keep going, please...

Query Tools ->Design