Tip 6: How to calculate the business days between two dates.

Tip 6: How to calculate the business days between two dates.



Hi everyone,


Following our Zoho Creator - Tips and Tricks series every fortnight, we are back today with a tip based on one of the most asked questions in the forum. That's right. This tip would help you calculate the business days between two dates excluding the weekend.

For example, if wish to know the number of working days in a particular month, you need to write a custom function to do this calculation.

Functions are nothing but a unit of code written to perform a specific task.


Let's see how to do this:


  1. // Here WorkDays is the name of the function.
  2. int WorkDays(date start_date, date end_date)
  3. {
  4. //total_days will store the value of numbers of days between start date and end date.
  5. total_days=(days360(input.start_date,input.end_date) +1);
  6. counter=leftpad("1",total_days).replaceAll(" ","1,").toList();
  7. //Here counter will generate a list like {1,1,1,1,1,1} with number of 1's based on value returned in total_days.
  8. week_ends=0;
  9. date_counter=input.start_date;
  10. for each index n in counter
  11. {
  12. //Use getDayOfWeek() to identify if it is a weekday or weekend. 
  13. if((date_counter.getDayOfWeek() == 1) || (date_counter.getDayOfWeek() == 7))
  14. {
  15. week_ends=(week_ends + 1);
  16. }
  17. //Now add one day for the next loop
  18.  date_counter=date_counter.addDay(1);}
  19. total_business_days=(total_days - week_ends);
  20. return total_business_days;
  21. }

 

Let's look at some of the built-in functions that we used in the above code:

days360 is a built-in function that returns the number of days between two given dates.


getDayOfWeek is a built-in function to get the day of the week corresponding to a date. It will return a number range from 1 to 7. The number 1 represents a Sunday, 2 represents a Monday and so on.

replaceAll is a built-in function that helps you replace all the occurrence of a particular substring in a sting.


toList is a built-in function that removes the given separator in a string, and replaces it with a comma.

Isn't it easy? Give it a try. If you have any doubts or queries regarding this tip, please feel free to add them as comments below. We would be happy to address them all.




    Access your files securely from anywhere

        All-in-one knowledge management and training platform for your employees and customers.






                              Zoho Developer Community




                                                    • Desk Community Learning Series


                                                    • Digest


                                                    • Functions


                                                    • Meetups


                                                    • Kbase


                                                    • Resources


                                                    • Glossary


                                                    • Desk Marketplace


                                                    • MVP Corner


                                                    • Word of the Day


                                                    • Ask the Experts





                                                              Manage your brands on social media



                                                                    Zoho TeamInbox Resources



                                                                        Zoho CRM Plus Resources

                                                                          Zoho Books Resources


                                                                            Zoho Subscriptions Resources

                                                                              Zoho Projects Resources


                                                                                Zoho Sprints Resources


                                                                                  Qntrl Resources


                                                                                    Zoho Creator Resources



                                                                                        Zoho CRM Resources

                                                                                        • CRM Community Learning Series

                                                                                          CRM Community Learning Series


                                                                                        • Kaizen

                                                                                          Kaizen

                                                                                        • Functions

                                                                                          Functions

                                                                                        • Meetups

                                                                                          Meetups

                                                                                        • Kbase

                                                                                          Kbase

                                                                                        • Resources

                                                                                          Resources

                                                                                        • Digest

                                                                                          Digest

                                                                                        • CRM Marketplace

                                                                                          CRM Marketplace

                                                                                        • MVP Corner

                                                                                          MVP Corner







                                                                                            Design. Discuss. Deliver.

                                                                                            Create visually engaging stories with Zoho Show.

                                                                                            Get Started Now


                                                                                              Zoho Show Resources

                                                                                                Zoho Writer

                                                                                                Get Started. Write Away!

                                                                                                Writer is a powerful online word processor, designed for collaborative work.

                                                                                                  Zoho CRM コンテンツ




                                                                                                    Nederlandse Hulpbronnen


                                                                                                        ご検討中の方




                                                                                                                • Recent Topics

                                                                                                                • sync two zoho crm

                                                                                                                  Hello everyone. Is it possible to sync 2 zoho crm? what would be the easiest way? I am thinking of Flow. I have a Custom Module that I would like to share with my client. We both use zoho crm. Regards.
                                                                                                                • Zoho Bookings - Feature Request - Services Which Include A Resource and Consultant

                                                                                                                  Hi Bookings Team, My feature request is to have the ability to add Consultants and Resources to Services. Use case: Your business provides first aid training and there are certain equpment you require to provide the half day training. There are only specific
                                                                                                                • Ask the Experts 27: Onboarding and managing support reps

                                                                                                                  Hello everyone, We are back with our Ask the Experts (ATE) series for 2026. This year, we bring experts to help you address customer support challenges using Zoho Desk. For our first ATE, we are getting into the human side of customer support. "Every
                                                                                                                • Map: Output None

                                                                                                                  Hi, Checking if you help me inspect this block The code below triggers during Successful form Submission from another Form. // rec_a = formA[ID!=0]; rec_b = formB[ID!=0]; ListA = List(); //subformA for each recA in rec_a.ItemSubform { for each recB in
                                                                                                                • Assign Meeting in records

                                                                                                                  It would be nice to be able to "call and assing" meetings from a record, for example from a Deal. Right now - calendar is synced with CRM - meetings show in calendar - you can go in each meeting and assign it to a record It would be nice to be able to
                                                                                                                • You have reached the maximum limit of bank accounts that can be connected to Zoho Books through token.

                                                                                                                  I can no longer connect to my bank account to download transactions into Zoho Books. I egt the error message: "You have reached the maximum limit of bank accounts that can be connected to Zoho Books through token. To connect more accounts, write to us
                                                                                                                • Sincronizar eventos de Bigin en Zoho Calendar (Zoho Mail)

                                                                                                                  Hola Me gustaría poder sincronizar mi Calendario de Zoho (Mail) con los eventos de Bigin. No veo la opción disponible.
                                                                                                                • Sales Receipts in UK Free tier

                                                                                                                  Is Sales Receipts available in UK Books, specifically at the Free tier? None of the options from the help pages are available to me.
                                                                                                                • Duplicate Leads Concerns with Round Robin and Lead Approval Process

                                                                                                                  It is great to have the Duplicate Lead Approval Process, there are a few issues with the process that I would greatly appreciate taken consideration in enhancing. It appears that A Lead comes in Lead owner assigned by the Round Robin Check for Duplicate,
                                                                                                                • My client requires me to have custom pdf file names to except payment for invoices, how can I customize this before emailing.

                                                                                                                  Hello! I love the program so far but there are a few things that are standing in the way. I hope you guys can code them in so I can keep the program for years to come. My client requires I customize the pdf file names I send in for billing. Can you please
                                                                                                                • How to see Statement Details Shown in Unclassified Transactions in All Transactions?

                                                                                                                  All, The list of Unclassified Transactions show the Statement Details and Descriptions. What is the method to see that column in the All Transactions list? -Thanks!
                                                                                                                • When I schedule calendar appointments in zoho and invite external emails, they do not receive invites

                                                                                                                  Hello, We have recently transitioned to zoho and are having a problem with the calendar feature. When we schedule new calendar appointments in zoho the invite emails aren't being sent to the external users that we list in participants. However, this works
                                                                                                                • Migrate different zoho subscription to zoho one

                                                                                                                  Dear We have different zoho subscription we need to migrate it to zoho one. Currently we are paying for zoho email, zoho expense, zoho payroll etc under different admin We need to move it too zoho one flexlible plan for all my employees
                                                                                                                • Bigin use in hospital- Human Med or Veterinary

                                                                                                                  I am looking for users who are in either human or veterinary medicine and use the CRM specifically for referral management tasks. Are you using the basic version? How many users update the CRM and is it effective? Did you pay for additional customizations?
                                                                                                                • Questions Regarding Helpdesk & SalesIQ Customization and Email Setup

                                                                                                                  Hello, I hope you’re doing well. I have a few questions regarding Helpdesk and SalesIQ: Can the emails sent to customers via helpdesk tickets be fully customized — including signature, subject line, and other elements? Also, is it possible to send these
                                                                                                                • Internal Fillable Contract with Zoho Writer (Before Sending to Client)

                                                                                                                  Hi everyone, I’m trying to automate the following process in Zoho CRM and would appreciate some guidance. Process: When a Deal moves to a specific stage, CRM triggers an automation. CRM sends a contract template to an internal team member so they can
                                                                                                                • How to sync overtime from zoho people to zoho payroll

                                                                                                                  Hi everyone, I’m currently setting up Zoho People with Zoho Payroll. While configuring the sync, I noticed I can only fetch Employee Profiles, LOP (Loss of Pay), and enable the Employee Portal. I can’t seem to find a way to automatically pull Overtime
                                                                                                                • Standardize email communication with Signature Template

                                                                                                                  Maintaining a consistent and professional signature across all outgoing emails is essential for any organization. However, when users manage their signatures individually, it often leads to inconsistencies like varying formats, missing designations, or
                                                                                                                • CRM x WorkDrive: File storage for new CRM signups is now powered by WorkDrive

                                                                                                                  Availability Editions: All DCs: All Release plan: Released for new signups in all DCs. It will be enabled for existing users in a phased manner in the upcoming months. Help documentation: Documents in Zoho CRM Manage folders in Documents tab Manage files
                                                                                                                • How can I export all Deluge code across the application?

                                                                                                                  I’m working on a application with multiple forms, reports, and HTML views, where Deluge scripts are used across workflows, field actions, and custom functions. Is there a way to export all Deluge scripts into a single file for easier search?
                                                                                                                • Zoho Books: tax is not automatically pulled from product-data anymore - why?

                                                                                                                  Hi, until a short time ago, you could set a default taxrate for each product/item. This taxrate automatically appeared each time the item was chosen in an invoice or quote. Why does this not work anymore? The field is still there at the product record,
                                                                                                                • Setting up property management in Zoho Books

                                                                                                                  Hi, I run a property management business that manages property complexes. There are multiple owners, some owning more than one property on the same complex. My role is to manage the fees they pay for maintenance of common areas, such as the swimming pool
                                                                                                                • Sync Attachments in Comments from Zoho Desk to Zoho Projects

                                                                                                                  Hello Zoho Desk Team, We hope you're doing well. We are actively using the Zoho Desk–Zoho Projects integration, especially for reporting and managing bugs/issues between support and development teams. Current Limitation: After creating a bugs/issues via
                                                                                                                • Zoho Creator to GMAIL API Setup - Where Do I Begin?

                                                                                                                  Does anyone know how to connect Zoho Creator to Google Workspace (Specifically GMAIL?) We have FLOW setup and working fine to send emails via GMAIL, but Flow doesn't accept file attachments which is a major problem. So, we need to be able to send an email
                                                                                                                • Kiosk Page Refresh

                                                                                                                  We have a Kiosk running from a button in contacts to update values and also add related lists, which works great, but when the kiosk is finished the page does not refresh to show the changes. Is there a way to force the contact to refresh/update when
                                                                                                                • How to call Functions and perform Write Operations using Page Scripts?

                                                                                                                  Hi everyone, How to call a function from a Zoho Creator application within a Page Script, also how to perform write operations (adding or updating records) using page scripts?
                                                                                                                • All new Address Field in Zoho CRM: maintain structured and accurate address inputs

                                                                                                                  Availability Update: 29 September 2025: It's currently available for all new sign-ups and for existing Zoho CRM orgs which are in the Professional edition exclusively for IN DC users. 2 March 2026: Available to users in all DCs except US and EU DC. 24
                                                                                                                • Setting GC session variable programatically in a website

                                                                                                                  Hi! Is there a way now to programatically set session variables from a website for a Guided Conversations? The current available methods are dependent on react-native.
                                                                                                                • Ticket Merge Error

                                                                                                                • Introducing Rollup summary in Zoho CRM

                                                                                                                  ------------------------------------------Moderated on 5th July'23---------------------------------------------- Rollup summary is now available for all organizations in all the DCs. Hello All, We hope you're well! We're here with an exciting update that
                                                                                                                • Refresh frequency

                                                                                                                  Dear Zoho Team, I really, truly appreciate that Zoho Books gets frequent updates. As a matter of fact this is how a good SaaS company should stay on top. However, I feel that I have to hit refresh almost every day. This was exciting at the beginning but
                                                                                                                • Update application by uploading an updated DS file

                                                                                                                  Is it possible? I have been working with AI on my desktop improving my application, and I have to keep copy pasting stuff... Would it be possible to import the DS file on top of an existing application to update the app accordingly?
                                                                                                                • Two-factor authentication (2FA) Log-in Problems

                                                                                                                  The Two-factor authentication (2FA) Login on my passwords doesn't match , so it wont accept login I'm down to my last backup code.
                                                                                                                • Re: Application Architecture in Zoho Creator — A Platform-Specific Deep Dive

                                                                                                                  A recent community post on application architecture made some excellent points about planning architecture early in Zoho Creator projects. The core message is right — Creator applications have a habit of growing organically into maintenance nightmares,
                                                                                                                • Remove my video

                                                                                                                  Hi, How can I remove my video so that I don't have to see myself. It's weird so I always remove my own video from what I see but cannot find this feature here. Thanks!
                                                                                                                • Client Script: Any plans to add support for multi-select field with onChange

                                                                                                                  Client Script is fantastic and the documentation lists multiselect form fields as unsupported. Just wondering if there are any plans to make this a supported field. https://www.zoho.com/crm/developer/docs/client-script/client-script-events.html 2. Field
                                                                                                                • Zoho Campaigns API endpoint for contact details

                                                                                                                  there is some REST API support for Zoho Campaigns, however, I am not able to find an endpoint for "get contact details".  in particular, I'd like to access contact's subscription status and also their topic. ideally there is all profile available including
                                                                                                                • Feature Reqeust - Include MPN In Selectable FIelds

                                                                                                                  I have noticed that the MPN is not available to show in the list view of Items. Please consider adding it as EAN, UPC and ISBN are all available, so it doesn't make much sense to exclude this similar option. Thanks for considering my feedback.
                                                                                                                • Experience effortless record management in CRM For Everyone with the all-new Grid View!

                                                                                                                  Hello Everyone, Hope you are well! As part of our ongoing series of feature announcements for Zoho CRM For Everyone, we’re excited to bring you another type of module view : Grid View. In addition to Kanban view, List view, Canvas view, Chart view and
                                                                                                                • Windows Desktop Application for Bigin

                                                                                                                  I'm finding the need for a standalone Bigin desktop app for Windows users. Most of my daily work is done through a browser, so I often have several open tabs while working with customers and checking product information, etc. With Bigin currently only
                                                                                                                • Next Page