Date, Number, and String Functions

Dates III

Given a datepart and a column of date or timestamp data type, we can increment date or timestamp values by a specified interval.

For example, in SQLite, the statement

DATETIME(time1, '+3 hours', '40 minutes', '2 days');

Would return a time 3 hours, 20 minutes, and 2 days after time1.

Imagine that each dessert in our baked_goods table is inspected 2 hours, 30 minutes, and 1 day after the manufacture time. To derive the inspection date for each baked good, we can use the following query

SELECT DATETIME(manufacture_time, '+2 hours', '30 minutes', '1 day') as inspection_time
FROM baked_goods;
Community Forums
Get help and ask questions in the Codecademy Forums
Report a Bug
If you see a bug or any other issue with this page, please report it here.