Working with date and time values in Zoho Flow

Working with date and time values in Zoho Flow

Different apps talk about date and time values in different ways. American, European, International—there are so many date formats, that it's a challenge to transfer date-time values across apps automatically. Some apps may not accept other date formats, while others may misinterpret the value. For example, if an app receives an input value as 04-03-2020, it may understand it as 4 March 2020, or 3 April 2020, depending on its configuration. 

When you build flows, you need to make sure that date-time values are converted accurately. This minimizes errors in your flow and ensures that the right values are conveyed to other apps. In this article, we'll learn how to identify, convert, and work with various date formats that your apps provide. Before we dive in to converting date formats in flows, let's look at the basic notations and formats we'll be using.

Before we dive in to converting date formats in flows, let's look at the basic notations and formats we'll be using.

Notations and formats

Basic notations

Letter

Date or Time component

Examples

y

Year

1996; 96

Y

Week year

2009; 09

M

Month in year

April, Apr, 04

w

Week in year

18

W

Week in month

3

d

Day in month

10

D

Day in year

211

E

Day name in week

Monday; Mon

a

AM or PM marker

PM

H

Hour in day (0-23)

2

h

Hour in AM/PM (1-12)

3

k

Hour in day (1-24)

21

K

Hour in AM/PM (0-11)

10

m

Minute in hour

54

s

Second in minute

30

S

Millisecond

853

X

ISO 8601 timezone

-08; -0800; -08:00


Common date and time formats

ISO 8601
This is a standardized way to represent date and time values, and is the most common format in which date-time is communicated across apps.

Date and time format:  yyyy-MM-ddThh:mm:ssXXX
E.g.: 2018-11-26T11:54:39+05:30

Date format: yyyy-MM-dd
E.g.: 2018-11-26

Unix timestamp  
This represents the number of seconds elapsed since 1 January 1970 (excluding leap seconds)
E.g.: 1546491981

American  
Format: MM/dd/yyyy
E.g.: 11/26/2018

European  
Format: dd/MM/yy
E.g.: 26/11/2018

International  
Format: yyyy-MM-dd
E.g.: 2018-11-26

Important points to note 

  1. UTC, GMT, etc. are ways of tracking time. For all practical scenarios, UTC and GMT will be the same.
  2. ISO 8601, RFC 1123, etc. are date-time formats. ISO 8601 is the accepted format in all the modern applications.
  3. The character T in the middle separates the year-month-day part from the hour-minute-second part. It should be parsed from the date-time value that you want in your applications. Use single quotes to parse it from the input value. For example, "yyyy-MM-dd'T'hh:mm:ss" should be given as the output format and not "yyyy-MM-ddThh:mm:ss".
  4. Use single quotes(' ') to parse any set of characters from a string that is given inside double quotes (" ").
  5. The character 'Z' at the end of a date-time format means the date-time is UTC. That is, an offset-from-UTC of zero hours-minutes-seconds.
  6. Instead of 'Z', if you see '+01:00', it means the timezone is one hour ahead of UTC at the moment, as noted by '+01:00'

Identify date formats in flows

When apps send data through APIs, they always use a specific format. You can look at the app's API documentation to identify the date format it uses. Some apps use different formats for different entities. Make sure you refer to the date format in the right section of the documentation.

Another way to find the date format is by looking at the data coming in to your flow. When you test the trigger, the output will contain the date value.
identify date format

When you configure actions, we try to display the accepted date format as much as possible.

Consider a flow that creates a project in Zoho Projects when a deal is created in Zoho CRM. When we look at the data CRM sends for a new deal, we see that the date is in yyyy-MM-dd format.
crm date format

While configuring the action in Zoho Projects, we see that it accepts only MM-dd-yyyy format.

Because of this inconsistency, we can't map the date values directly from CRM to Projects. Now that we've identified what we need to work with, let's look at how to convert the date value.

Convert date formats

To convert date from CRM to Project's format, we use a custom function between the trigger and action.

Use this code to create your custom function:

  1. string dateformat(string dateStr, string inputFormat, string outputFormat)
  2. {
  3.   myDate = dateStr.toTime(inputFormat);
  4.   return myDate.tostring(outputFormat);
  5. }

This function requires three inputs: the date from CRM trigger, its format, and the format accepted by Projects. This custom function can convert only one date and time value during an execution.

In our flow, we'll use the custom function between the trigger and the action. We need to map two date values: start and end date. So we use the custom function twice and map the output of the functions to the respective fields in Zoho Projects.

You can also include the date format in the custom function code, if you're going to use the function for a specific case.

  1. string dateFormatCal(string dateStr)
  2. {
  3.   myDate = dateStr.toTime("yyyy-MM-dd HH:mm:ss");
  4.   return myDate.toString("MM-dd-yyyy");
  5. }

This function converts any date format to the standard format of yyyy-MM-dd HH:mm:ss, then to the specified format (MM-dd-yyyy in this case). If you choose to use this kind of function, you need to write a different function for each output date format.

Let's take another example of date-time format conversion between Zoho CRM and Zoho Desk. Suppose the date-time value coming from Zoho CRM's output is 2021-07-20T10:33:00+05:30, and you want it to be converted to Zoho Desk's format, which should look like 2021-07-20T10:33:00.000Z.
 
To do this, you should configure your custom function in the following manner:
 
  1. string dateFormat(string dateStr, string fromFormat, string toFormat)
  2. {
  3.     dateObj = dateStr.toTime(" yyyy-MM-dd'T'HH:mm:ss");
  4.     return dateObj.toString("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
  5. }

Add or subtract date-time values

When you work across countries, you need to make sure your flows work with varying time zones. Custom functions help convey these date-time values across time zones accurately.

You can also use custom functions to add or subtract date-time values and set reminders. To understand how to do this, let's build a flow to notify your team on Zoho Cliq a day before a meeting scheduled in your Google Calendar.

We'll use this custom function to calculate the day before the event:

  1. string subDay(string dateStr)
  2. {
  3.   dateObj = dateStr.toDate("yyyy-MM-dd'T'HH:mm:ss");
  4.   resultDate = dateObj.subDay(1);
  5.   return resultDate.toString("yyyy-MM-dd");
  6. }

The date of the meeting is the input of this custom function. This function then calculates the date before the day of the meeting.

Now we add a delay that stalls the flow until the date provided by the custom function. The flow then sends a reminder to the team.

Depending on your requirements, you can modify these functions or write your own. Refer to the Deluge help page to learn more about functions you can use.

If you'd like to talk with us about date and time formats, shoot us an email at support@zohoflow.com.


    Access your files securely from anywhere

      Zoho CRM Training Programs

      Learn how to use the best tools for sales force automation and better customer engagement from Zoho's implementation specialists.

      Zoho CRM Training
        Redefine the way you work
        with Zoho Workplace

          Zoho DataPrep Personalized Demo

          If you'd like a personalized walk-through of our data preparation tool, please request a demo and we'll be happy to show you how to get the best out of Zoho DataPrep.

          Zoho CRM Training

            Create, share, and deliver

            beautiful slides from anywhere.

            Get Started Now


              Zoho Sign now offers specialized one-on-one training for both administrators and developers.

              BOOK A SESSION





                          Quick Links Workflow Automation Data Collection
                          Web Forms Enterprise Begin Data Collection
                          Interactive Forms Workplace Data Collection App
                          CRM Forms Customer Service Accessible Forms
                          Digital Forms Marketing Forms for Small Business
                          HTML Forms Education Forms for Enterprise
                          Contact Forms E-commerce Forms for any business
                          Lead Generation Forms Healthcare Forms for Startups
                          Wordpress Forms Customer onboarding Order Forms for Small Business
                          No Code Forms Construction RSVP tool for holidays
                          Free Forms Travel
                          Prefill Forms Non-Profit

                          Intake Forms Legal
                          Mobile App
                          Form Designer HR
                          Mobile Forms
                          Card Forms Food Offline Forms
                          Assign Forms Photography
                          Mobile Forms Features
                          Translate Forms Real Estate Kiosk in Mobile Forms
                          Electronic Forms

                          Notification Emails for Forms Alternatives Security & Compliance
                          Holiday Forms Google Forms alternative  GDPR
                          Form to PDF Jotform alternative HIPAA Forms
                          Email Forms
                          Encrypted Forms
                          Embeddable Forms
                          Secure Forms
                          Drag and Drop form builder
                          WCAG


                                            You are currently viewing the help pages of Qntrl’s earlier version. Click here to view our latest version—Qntrl 3.0's help articles.




                                                Manage your brands on social media

                                                  Zoho Desk Resources

                                                  • Desk Community Learning Series


                                                  • Digest


                                                  • Functions


                                                  • Meetups


                                                  • Kbase


                                                  • Resources


                                                  • Glossary


                                                  • Desk Marketplace


                                                  • MVP Corner


                                                  • Word of the Day


                                                    Zoho Marketing Automation

                                                      Zoho Sheet Resources

                                                       

                                                          Zoho Forms Resources


                                                            Secure your business
                                                            communication with Zoho Mail


                                                            Mail on the move with
                                                            Zoho Mail mobile application

                                                              Stay on top of your schedule
                                                              at all times


                                                              Carry your calendar with you
                                                              Anytime, anywhere




                                                                    Zoho Sign Resources

                                                                      Sign, Paperless!

                                                                      Sign and send business documents on the go!

                                                                      Get Started Now




                                                                              Zoho TeamInbox Resources



                                                                                      Zoho DataPrep Resources



                                                                                        Zoho DataPrep Demo

                                                                                        Get a personalized demo or POC

                                                                                        REGISTER NOW


                                                                                          Design. Discuss. Deliver.

                                                                                          Create visually engaging stories with Zoho Show.

                                                                                          Get Started Now









                                                                                                              • Related Articles

                                                                                                              • Zoho Meeting

                                                                                                                What is Zoho Meeting? Zoho Meeting is a secure online meeting platform and webinar solution that helps people find new ways to collaborate and work remotely with efficacy. How to connect your Zoho Meeting account to Zoho Flow Select the trigger or ...
                                                                                                              • Best practices while using Zoho Flow

                                                                                                                Workflows form a part of business processes and day-to-day activities. An effective business workflow requires a good deal of planning and a set of practices that ensure that they continue to work as intended. Similarly, automated workflows can also ...
                                                                                                              • Integrating Google Forms using Zoho Flow

                                                                                                                Google Forms has become a popular web-form tool for collecting contacts, surveys, and quizzes. Creating a form and consolidating the responses in a spreadsheet is a straightforward process and takes only a few minutes. However, what if you need to ...
                                                                                                              • HIPAA compliance in Zoho Flow

                                                                                                                The Health Insurance Portability and Accountability Act (including the Privacy Rule, Security Rule, Breach Notification Rule, and Health Information Technology for Economic and Clinical Health Act) ("HIPAA"), requires Covered Entities and Business ...
                                                                                                              • How to use Fetch actions in Zoho Flow

                                                                                                                Business processes come in all shapes and sizes. Your automation workflows need to adapt to these processes for maximum productivity. Sometimes when you build these flows, you might not find all the data you need. This is where fetch actions can ...
                                                                                                                Wherever you are is as good as
                                                                                                                your workplace

                                                                                                                  Resources

                                                                                                                  Videos

                                                                                                                  Watch comprehensive videos on features and other important topics that will help you master Zoho CRM.



                                                                                                                  eBooks

                                                                                                                  Download free eBooks and access a range of topics to get deeper insight on successfully using Zoho CRM.



                                                                                                                  Webinars

                                                                                                                  Sign up for our webinars and learn the Zoho CRM basics, from customization to sales force automation and more.



                                                                                                                  CRM Tips

                                                                                                                  Make the most of Zoho CRM with these useful tips.



                                                                                                                    Zoho Show Resources