MINUTES_ADD
Descriptionβ
Adds a specified number of minutes to a datetime value and returns a new datetime value.
Syntaxβ
MINUTES_ADD(<datetime>, <minutes>)
Parametersβ
Parameter | Description |
---|---|
<datetime> | The input datetime value, which can be of type DATE, DATETIME, or DATETIMEV2 |
<minutes> | The number of minutes to add, of type INT; can be positive or negative |
Return Valueβ
Returns a value of type DATETIME, representing the datetime value after adding the specified number of minutes.
Exampleβ
SELECT MINUTES_ADD("2020-02-02", 1);
+-----------------------------------------------------+
| minutes_add(cast('2020-02-02' as DATETIMEV2(0)), 1) |
+-----------------------------------------------------+
| 2020-02-02 00:01:00 |
+-----------------------------------------------------+
Note:
- When the number of minutes added is negative, it effectively subtracts the corresponding number of minutes.
- The function automatically handles cases that cross hours and days.
- If the input parameter is NULL, the function returns NULL.