Add Minutes to a Time Value in SQLite

In SQLite, we can use the TIME() function to add a given number of minutes to a time value.

If we’re dealing with datetime values, we can use the DATETIME() function.

Example

Here’s an example that uses the TIME() function:

SELECT TIME('22:50:10', '+1 minute');

Result:

22:51:10

We can subtract the amount by replacing + with -.

Omitting + results in the amount being added, as if we’d used +:

SELECT TIME('22:50:10', '1 minute');

Result:

22:51:10

We can specify the minutes in plural or non-plural form. In other words, minute is equivalent to minutes:

SELECT 
    TIME('22:50:10', '20 minute') AS minute,
    TIME('22:50:10', '20 minutes') AS minutes;

Result:

minute    minutes 
--------  --------
23:10:10  23:10:10

The DATETIME() Function

This example uses the DATETIME() function to add fifteen minutes to a datetime value:

SELECT DATETIME('2050-08-21', '+15 minutes');

Result:

2050-08-21 00:15:00 

In this case, I passed a date value and the function returned a datetime value with the number of minutes being added to 00:00:00.

Here’s an example with a datetime value:

SELECT DATETIME('2050-08-21 23:30:45', '+47 minutes');

Result:

2050-08-22 00:17:45

Here, the number of minutes was sufficient to push the date over to the next day.