totn MariaDB Functions

MariaDB: ADDTIME Function

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

Description

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

Syntax

The syntax for the ADDTIME function in MariaDB is:

ADDTIME( start_value, time )

Parameters or Arguments

start_value
The time or datetime value to which the time interval should be added.
time
The value of the time interval that you wish to add. It can be a positive or negative value.

Note

Applies To

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

  • MariaDB 10

Example

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

For example:

SELECT ADDTIME('2014-05-17 08:44:21.000001', '2.000001');
Result: '2014-05-17 08:44:23.000002'

SELECT ADDTIME('2014-05-17 08:44:21.000001', '3:2.000001');
Result: '2014-05-17 11:46:21.000002'

SELECT ADDTIME('2014-05-17 08:44:21.000001', '4:3:2.000001');
Result: '2014-05-17 12:47:23.000002'

SELECT ADDTIME('2014-05-17 08:44:21.000001', '5 4:3:2.000001');
Result: '2014-05-22 12:47:23.000002'

SELECT ADDTIME('01:15:23.999998', '0.000001');
Result: '01:15:23.999999'

SELECT ADDTIME('01:15:23.999998', '5.000001');
Result: '01:15:28.999999'

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

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