subMinutes
Table of Contents
Overview
The subMinutes function takes a date-time or time value and numberOfMins as arguments. It returns the date-time or time value after subtracting the specified number of minutes from it.
Return Type
The return type of the function depends on the value it acts upon.
Value | Data Type |
date-time | DATE-TIME |
time | TIME |
Syntax
<variable> = <dateTimeValue>.subMinutes(<numberOfMins>);
(OR)
<variable> = subMinutes(<dateTimeValue>, <numberOfMins>);
(OR)
<variable> = <timeValue>.subMinutes(<numberOfMins>);
(OR)
<variable> = subMinutes(<timeValue>, <numberOfMins>);
where,
Parameter | Data type | Description |
<variable> | DATE-TIME/TIME | Variable which will contain the calculated date-time or time value. |
<dateTimeValue> (if the value is date-time) | DATE-TIME | The date-time value from which the specified number of minutes should be subtracted. The date-time value can be specified without a time value, in which case 00:00:00 will be taken as the default time value. If the hour value is specified as 24 or more, the date-time value be reset to 00:00:00. If the minutes value is specified as 60 or more, the mm:ss value will be reset to 00:00, if the seconds value is specified as 60 or more, the ss value will be reset to 00. A runtime error will be encountered if:
Refer date-time data type to learn more about date-time data type. |
<timeValue> (if the value is time) | TIME | The time value from which the specified number of minutes should be subtracted. Time data type is currently supported only in Zoho Creator TIME values are represented in the formats - hh:mm:ss a (12-hour format) and HH:mm:ss (24-hour format) A runtime error will be encountered if:
Refer time data type to learn more about time data type. |
<numberOfMins> | NUMBER | The number of minutes to be subtracted from the date-time or time value. A negative number will add the specified number of minutes from the date-time or time value. |
Examples
Date-Time Examples:
currentDate = '02-Jan-2019'; info currentDate.subMinutes(1); // Returns '01-Jan-2019 23:59:00'
currentDate = '01-Jan-2019 23:59:10'; info currentDate.subMinutes(2); // Returns '01-Jan-2019 23:57:10'
Time Examples (only for Creator):
// The below code tries to add hours to a "time" value beyond the 24-hour range timeValue = '00:00:00'; info timeValue.subMinutes(-4); // Returns '00:04:00'
currentTime = '13:15:10'; info currentTime.subMinutes(1); // Returns '13:14:10'