IniziaInizia gratis

Calculating the expected return date

So now that you've practiced how to add and subtract timestamps and perform relative calculations using intervals, let's use those new skills to calculate the actual expected return date of a specific rental. As you've seen in previous exercises, the rental_duration is the number of days allowed for a rental before it's considered late. To calculate the expected_return_date you will want to use the rental_duration and add it to the rental_date.

Questo esercizio fa parte del corso

Functions for Manipulating Data in PostgreSQL

Visualizza il corso

Istruzioni dell'esercizio

  • Convert rental_duration by multiplying it with a 1-day INTERVAL.
  • Add it to the rental date.

Esercizio pratico interattivo

Prova a risolvere questo esercizio completando il codice di esempio.

SELECT
    f.title,
	r.rental_date,
    f.rental_duration,
    -- Add the rental duration to the rental date
    ___ '1' day ___ f.___ + ___ AS expected_return_date,
    r.return_date
FROM film AS f
    INNER JOIN inventory AS i ON f.film_id = i.film_id
    INNER JOIN rental AS r ON i.inventory_id = r.inventory_id
ORDER BY f.title;
Modifica ed esegui il codice