totn MariaDB Functions

MariaDB: SUBTIME Function

This MariaDB tutorial explains how to use the MariaDB SUBTIME function with syntax and examples.

Description

The MariaDB SUBTIME function returns a time/datetime value after which a certain time interval has been subtracted.

Syntax

The syntax for the SUBTIME function in MariaDB is:

SUBTIME( start_value, time )

Parameters or Arguments

start_value
A time or datetime value to which the time interval should be subtracted.
time
The value of the time interval that you wish to subtract. It can be a positive or negative number.

Note

Applies To

The SUBTIME function can be used in the following versions of MariaDB:

  • MariaDB 10

Example

Let's look at some MariaDB SUBTIME function examples and explore how to use the SUBTIME function in MariaDB.

For example:

SELECT SUBTIME('2014-05-17 08:44:21.000002', '2.000001');
Result: '2014-05-17 08:44:19.000001'

SELECT SUBTIME('2014-05-17 08:44:21.000002', '3:2.000001');
Result: '2014-05-17 05:42:21.000001'

SELECT SUBTIME('2014-05-17 08:44:21.000002', '4:3:2.000001');
Result: '2014-05-17 04:41:19.000001'

SELECT SUBTIME('2014-05-17 08:44:21.000002', '5 4:3:2.000001');
Result: '2014-05-12 04:41:19.000001'

SELECT SUBTIME('01:15:23.999998', '0.000001');
Result: '01:15:23.999997'

SELECT SUBTIME('01:15:23.999998', '5.000001');
Result: '01:15:18.999997'

SELECT SUBTIME('01:15:23.000001', '8:12:15.003441');
Result: '-06:56:52.003440'

SELECT SUBTIME('01:15:23.000001', '-8:12:15.003441');
Result: '09:27:38.003442'