Subtract Minutes from a Time Value in SQLite

In SQLite, we can use the TIME() function to subtract one or more minutes from a time value.

For datetime values, we can use the DATETIME() function.

Example

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

SELECT TIME('16:30:45', '-1 minute');

Result:

16:29:45

If we wanted to add the amount, we could replace - with +, or omit it altogether.

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

SELECT 
    TIME('16:30:45', '-30 minute') AS minute,
    TIME('16:30:45', '-30 minutes') AS minutes;

Result:

minute    minutes 
--------  --------
16:00:45  16:00:45

Specified in Seconds

We can also subtract minutes based on the number of seconds:

SELECT TIME('16:30:45', '-60 seconds');

Result:

16:29:45

The DATETIME() Function

This example uses the DATETIME() function to subtract minutes from a datetime value:

SELECT DATETIME('2050-08-21 16:30:45', '-30 minutes');

Result:

2050-08-21 16:00:45