Brightlane's HR team schedules a probation review 30 days after each hire date.
Write a query to return the review date for a hire on '2024-03-15', computed as the hire date plus 30 days.
Output:
- A single row with one column,
review_date, containing the projected review date.
Schema · ecommerce 5 tables
Run previews · Check grades
Write a query, then run it to see results here.
Worked solution Try it yourself first
SELECT
'2024-03-15'::date + INTERVAL '30 days' AS review_date The shape
Adding INTERVAL '30 days' to a date shifts that date forward by exactly thirty calendar days and returns the resulting point in time. The expression evaluates once and produces a single dated value: the projected review date for the hire.
Clause by clause
SELECT '2024-03-15'::date + INTERVAL '30 days' AS review_datebuilds the result in two steps. The::datecast pins the literal'2024-03-15'as a calendar date so the addition runs against the right type. Adding a fixed-dayINTERVALthen advances the date thirty days, landing on April 14, 2024. The aliasAS review_datenames the output column to match what the HR scheduler expects.
Why INTERVAL '30 days' and not adding an integer
PostgreSQL does not let you add a raw number to a date. Writing '2024-03-15'::date + 30 reads ambiguously to the parser, since the integer could mean days, months, or something else entirely. The INTERVAL syntax names the unit explicitly, which is what date arithmetic requires. A fixed-day interval is unambiguous: thirty days is thirty days, regardless of which month the addition lands in.
You practiced date + INTERVAL '30 days' — add a fixed-day duration to a date to produce the corresponding future point in time.