THE WORLD'S LARGEST WEB DEVELOPER SITE

MySQL ADDTIME() Function

❮ MySQL Functions

Example

Add 2 seconds to a time and return the datetime:

SELECT ADDTIME("2017-06-15 09:34:21", "2");
Try it Yourself »

Definition and Usage

The ADDTIME() function returns a time/datetime after a certain time interval has been added.

Syntax

ADDTIME(start_value, time)

Parameter Values

Parameter Description
start_value Required.  The time or datetime to be modified
time Required. The time interval to add to start_value

Technical Details

Works in: MySQL 5.7, MySQL 5.6, MySQL 5.5, MySQL 5.1, MySQL 5.0, MySQL 4.1.1

More Examples

Example

Add 5 seconds and 3 microseconds to a time and return the datetime:

SELECT ADDTIME("2017-06-15 09:34:21.000001", "5.000003");
Try it Yourself »

Example

Add 2 hours, 10 minutes, 5 seconds, and 3 microseconds to a time and return the datetime:

SELECT ADDTIME("2017-06-15 09:34:21.000001", "2:10:5.000003");
Try it Yourself »

Example

Add 5 days, 2 hours, 10 minutes, 5 seconds, and 3 microseconds to a time and return the datetime:

SELECT ADDTIME("2017-06-15 09:34:21.000001", "5 2:10:5.000003");
Try it Yourself »

Example

Add 2 hours, 10 minutes, 5 seconds, and 3 microseconds to a time and return the time:

SELECT ADDTIME("09:34:21.000001", "2:10:5.000003");
Try it Yourself »

❮ MySQL Functions