How to find time difference between Date-Times and set to Time field of Creator

How to find time difference between Date-Times and set to Time field of Creator

STEP 1. FIND TIME GAP using `timeBetween`

  1. startTime = zoho.currenttime.subHour(2).subMinutes(24).subSeconds(4);
  2. endTime = zoho.currenttime;
  3. timeGap = startTime.timeBetween(endTime);

STEP 2: Structure Time String for Time Field

There's an issue with the time_gap function. It only returns a value when there's a difference between the compared times. If there's no difference, the function returns nothing.

To address this, we can loop through a range of three values (0 to 2) and replace any empty responses with "00".
  1. timeList = timeGap.toList(":");
  2. finalTime = "";
  3. loopArr = [0,1,2];
  4. for each i in loopArr {
  5. scaleTime = (if(timeList.size() > i,timeList.get(i), "00").toString().leftPad(2)).replaceAll(" ", "0");
  6. finalTime = finalTime +":"+ scaleTime;
  7. }
  8. info finalTime.removeFirstOccurence(":");
You can use finalTime variable to assign in Time field.

Coding is fun :) Have a great day!
    Zoho Desk Resources

    • Desk Community Learning Series


    • Digest


    • Functions


    • Meetups


    • Kbase


    • Resources


    • Glossary


    • Desk Marketplace


    • MVP Corner


    • Word of the Day


      Zoho CRM Plus Resources

        Zoho Books Resources


          Zoho Subscriptions Resources

            Zoho Projects Resources


              Zoho Sprints Resources


                Zoho Orchestly Resources


                  Zoho Creator Resources


                    Zoho WorkDrive Resources



                      Zoho Campaigns Resources

                        Zoho CRM Resources

                        • CRM Community Learning Series

                          CRM Community Learning Series


                        • Tips

                          Tips

                        • Functions

                          Functions

                        • Meetups

                          Meetups

                        • Kbase

                          Kbase

                        • Resources

                          Resources

                        • Digest

                          Digest

                        • CRM Marketplace

                          CRM Marketplace

                        • MVP Corner

                          MVP Corner




                          Zoho Writer Writer

                          Get Started. Write Away!

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

                            Zoho CRM コンテンツ




                              ご検討中の方