MulaiMulai sekarang secara 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.

Latihan ini adalah bagian dari kursus

Functions for Manipulating Data in PostgreSQL

Lihat Kursus

Petunjuk latihan

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

Latihan interaktif praktis

Cobalah latihan ini dengan menyelesaikan kode contoh berikut.

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;
Edit dan Jalankan Kode