Curriculum
Course: MYSQL
Login

Curriculum

MYSQL

MySQL References

0/140
Text lesson

ADDTIME

Example

Add 2 seconds to a given time and return the resulting datetime.

SELECT ADDTIME(“2017-06-15 09:34:21”“2”);

Definition and Usage

The ADDTIME() function adds a specified time interval to a time or datetime value and returns the updated time or datetime.

Syntax

ADDTIME(datetimeaddtime)

Parameter Values

Parameter

Description

datetime

Mandatory: The time or datetime value to be modified

addtime

Mandatory: The time interval to add to the datetime value. Both positive and negative values are permitted.

Technical Details

Works in:

 From MySQL version 4.0

More Examples

Example

Add 5 seconds and 3 microseconds to a given time and return the resulting datetime.

SELECT ADDTIME(“2017-06-15 09:34:21.000001”“5.000003”);

Example

Add 2 hours, 10 minutes, 5 seconds, and 3 microseconds to a given time, then return the resulting datetime.

SELECT ADDTIME(“2017-06-15 09:34:21.000001”“2:10:5.000003”);

Example

Add 5 days, 2 hours, 10 minutes, 5 seconds, and 3 microseconds to a given time, then return the resulting datetime.

SELECT ADDTIME(“2017-06-15 09:34:21.000001”“5 2:10:5.000003”);

Example

Add 2 hours, 10 minutes, 5 seconds, and 3 microseconds to a given time, then return the resulting time.

SELECT ADDTIME(“09:34:21.000001”“2:10:5.000003”);