Administrator: Receipts Page 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 More

Make a Date

DateDiff finds the difference between two dates. Microsoft Access uses Now() for the current date. The code looks like this:

 

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

 

Where DaysRented is a Label

DataDiff() 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”

 

Try it: Calculate the Date

Open rptCustomerReceiptSQ in Design View.

Insert a new column into your query.

Type the DateDiff code:

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

 

Test your results and Save the query.

Home ->View ->Query Design
 

 

  Microsoft Access 2007 Exam 77-605 Topic: 4. Creating and modifying queries 

  4.2. Modify queries

  4.2.4.   Create calculated fields in queries: Add fields to calculations