ADDTIME Function

Description

The ADDTIME function adds or subtracts a value of specific time.

The first argument is DATE, DATETIME, TIMESTAMP, or TIME type and the second argument is TIME, DATETIME, or TIMESTAMP type. Time should be include in the second argument, and the date of the second argument is ignored. The return type for each argument type is follows:

First Argument Type

Second Argument Type

Return Type

Note

TIME

TIME, DATETIME, TIMESTAMP

TIME

The result value must be equal to or less than 24 hours.

DATE

TIME, DATETIME, TIMESTAMP

DATETIME

DATETIME

TIME, DATETIME, TIMESTAMP

DATETIME

date/time string

TIME, DATETIME, TIMESTAMP or time string

VARCHAR

The result string includes time.

Syntax

ADDTIME( expr1, expr2)

Example

SELECT ADDTIME(datetime'2007-12-31 23:59:59', time'1:1:2');

 addtime(datetime '2007-12-31 23:59:59', time '1:1:2')

========================================================

01:01:01.000 AM 01/01/2008

 

SELECT ADDTIME(time'01:00:00', time'02:00:01');

 addtime(time '01:00:00', time '02:00:01')

============================================

03:00:01 AM