Choose where you’d like to start

addBusinessHour

Note: This task is applicable to all services except Zoho Creator

Overview

The addBusinessHour function adds/subtracts the specified business hours to/from the input dateTimeValue. 

Note: It allows for defining weekends, holiday lists, and business hours

Return Type

Syntax

<variable> = <dateTimeValue>.addBusinessHour(<no_of_hours>, <weekends_list>, <holiday_list>, <business_hours>);

where,

ParameterData typeDescription
<variable>DATE-TIMEVariable which will contain the returned date-time value after adding/subtracting the required number of hours.
<dateTimeValue>DATE-TIME/TEXT

The date-time value to which the required number of business hours will be added/subtracted.

<no_of_hours>NUMBER / DECIMAL

The number of business hours to be added to/ subtracted from the date-time value.

Note:
  • To subtract business hours from the input date-time values, supply negative value. For example, to subtract one business hour from the input date-time value, supply -1 as value to this param.
  • To add/ subtract business minutes, supply decimal value. For example, to add one business minute to the input date-time value, supply 0.1 as value to this param.

<weekends_list>

(optional)

COLLECTION
(OF TEXT)

The list of weekends that will be considered while adding/ subtracting business hours.

Note: By default, the weekends list is {Saturday, Sunday}

<holidays_list>

(optional)

COLLECTION
(OF DATES)

The list of holidays that will be considered while adding/ subtracting business hours.

Note: If no holidays are provided, any day (except weekends) will be considered a working day.

<business_hours>

(optional)

COLLECTION

The collection of business hours that will be considered while adding/ subtracting business hours.

The format is {"start":<start_hour>, "end":<end_hour>}

Note: By default, the business hours are between 9AM (9) and 5PM (17). The business hours are represented in 24 hour format only.

Examples

The below example illustrates adding 2 business hours to the 1st of January 2020 at 4PM. It declares Saturday and Sunday as weekends. It also lists the 2nd and 3rd of January as holidays. The workday starts at 10 AM and ends at 5PM. 

 meeting_time = "1-Jan-2020 16:00:00".addBusinessHour(2, {"Saturday", "Sunday"}, {'2-Jan-2020','3-Jan-2020'}, {"start":"10","end":"17"}); // meeting_time gets the value '06-Jan-2020 10:00:00' assigned to it.
   // When two hours are added to 01-Jan-2020 16:00:00, the task adds an hour which makes it 1-Jan-2020 17:00:00. Adding further would reach end of the day. Since the next two days are holidays and the two following are weekends, the next working day is identified as Monday. So, adding one hour to it, the required date is returned as 06-Jan-2020 10:00:00​

Related Links

Get Started Now

Execute