Brightlane's event scheduling platform shifts a meeting start time forward by 3 hours to accommodate a rescheduled call.
Write a query to return the new start time produced by adding 3 hours to the timestamp '2024-01-15 09:00:00'.
Output:
- A single row with one column,
new_start_time, typed as a timezone-naive timestamp.
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-01-15 09:00:00'::TIMESTAMP + INTERVAL '3 hours' AS new_start_time The shape
Adding INTERVAL '3 hours' to a timestamp shifts that timestamp forward by three hours and returns a value of the same timestamp type. The meeting that was at nine in the morning becomes a meeting at noon, with the rest of the calendar position untouched.
Clause by clause
SELECT '2024-01-15 09:00:00'::timestamp + INTERVAL '3 hours' AS new_start_timebuilds the rescheduled start time. The::timestampcast pins the literal as a timezone-naive timestamp, which is the type the scheduling platform stores. Adding anINTERVALof three hours advances the time-of-day component without crossing a calendar boundary in this case. The aliasAS new_start_timelabels the output.
Why the result is a TIMESTAMP and not a DATE
When an INTERVAL is added to a DATE, TIMESTAMP, or TIMESTAMPTZ, the return type is the same as the input. Because the left side is TIMESTAMP, the result is TIMESTAMP. The hours-and-minutes precision of the source value is preserved through the arithmetic, which is what a scheduling system needs: shifting a meeting by three hours has to land on a value that still carries a time-of-day, not a value that collapses to midnight.
You practiced timestamp + INTERVAL '3 hours' — shift a point in time forward by a sub-day duration.