Function Reference

ADDTIME

Adds the specified time to a time or datetime value.

MySQL 8.1
ADDTIME(datetime, time)

Parameters

datetimeDATETIME
Time or datetime
timeTIME
Time to add, can be negative and include days: «1 02:00:00»

Return value

A datetime if datetime contains a date, otherwise a time (TIME) not beyond 838:59:59; NULL if an argument is NULL

Examples

An hour added to a datetime

MySQL 8.1
SELECT ADDTIME('2022-06-16 23:30:00', '01:00:00') AS shifted;
shifted
2022-06-17 00:30:00

Negative time and days

MySQL 8.1
SELECT ADDTIME('10:00:00', '-02:30:00') AS earlier,
	ADDTIME('10:00:00', '1 02:00:00') AS plus_day;
earlierplus_day
07:30:0036:00:00

Class start with a delay

MySQL 8.1
SELECT id,
	start_pair,
	ADDTIME(start_pair, '00:10:00') AS start_with_delay
FROM Timepair;
idstart_pairstart_with_delay
108:30:0008:40:00
209:20:0009:30:00
310:15:0010:25:00
411:05:0011:15:00
512:50:0013:00:00
613:40:0013:50:00
714:35:0014:45:00
815:25:0015:35:00

Details

The first argument must contain a time. A date without a time is read as a time, and the result makes no sense: ADDTIME('2022-06-16', '01:00:00') returns 01:20:22. For dates, use DATE_ADD or + INTERVAL.

The paired function SUBTIME subtracts time. PostgreSQL has no such functions; time is added with an operator: value + INTERVAL '1 hour'.

See also