Home   Blog   News   Courses and Guides   Services   About Us   Search

 

Go to:  Level 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17

Level 16: Practice

 

Calculate the Date Difference, part two

Open the query named rptCustomerReciptByDateSQ.

Our calculations are based on the following field:

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

 

Change the field:

          DaysRented: DateDiff("d",[Date],[DateReturned])

 

First, determine the status of the movie rentals. Create a new field:

Status: IIf([DateReturned] Is Null,"Outstanding",[DateReturned])

 

Now, how should we calculate the overdue movies? If there is no return date, then what is the difference from the rental date and today’s date? If there is a return date, is it greater than the 1, 2, or 3-day rental?

 

Test this code in the rptCustomerReciptByDateSQ and determine if it calculates correctly, please.

 

Overdue: IIf([DateReturned] Is Null,DateDiff("d",[Date],Now())-(Left([Description],1)),DateDiff("d",[Date],[DateReturned])-(Left([Description],1)))