Type conversion functions

Type conversion functions

toDate

The toDate function takes an expression as an argument, and returns the expression (containing a date-time value) in the date format as specified in application settings. 
This function takes an optional argument dateTimeMapping when the given expression is of text data type. It is used to denote the date-time components for which the values in the text stand for.

Return Type

DATE-TIME

Syntax

  1. <variable>=<expression>.toDate(<dateTimeMapping>);
(OR)
  1. <variable>=toDate(<expression>,<dateTimeMapping>);
where,


Examples

  1.  dateTimeString="01,11,2019 1:30:00 pm"; 
  2.  info toDate(dateTimeString,"MM,d,yyyy"); 
  3.  // MM,d,yyyy is to denote the components in the expression
  4.  // So the value for MM is 01 (January), the value for d is 11, and the value for yyyy is 2019
  5.  // Assuming that the date time format set in application settings is dd-MMM-yyyy, the value returned is 11-Jan-2019

toDateTime

The toDateTime function takes an expression as an argument, and returns the expression (containing a date-time value) in the date format as specified in application settings.
This function takes an optional argument dateTimeMapping when the given expression is of text data type. It is used to denote the date-time components for which the values in the text stand for.

Return Type

DATE-TIME

Syntax

  1. <variable>=<expression>.toDateTime(<dateTimeMapping>);
where,

Examples

  1. currentTime="01-11-2019 13:30:00";//Assuming, date time format set in application settings is dd-MMM-yyyy.
  2. formatted_date = toDateTime(currentTime,"MM-d-yy");// formatted_date is assigned the value '11-Jan-2019 13:30:00'
  3. toDecimal

toJSONList

The toJSONList function takes a text JSON array as an argument, and returns it as a list.

Return Type

LIST

Syntax

  1. <variable>=<json_text>.toJSONList();
where,

Examples

The example below retrieves a value inside Collection from a JSON.
  1.  json_text = "{Name:'Lia Shelton', OrderNo:[343,443,577]}";
  2.  orderNo = json_text.getJSON("OrderNo");
  3.  info orderNo.toJSONList(); // Returns 343,443,577
The example below retrieves IDs of all employees in the form of a Collection from a JSON.
  1. response = "{\"data\" : [{\"id\":1, \"firstname\":\"John\", \"lastName\":\"Day\"},  {\"id\":2, \"firstname\":\"Patricia\",\"lastname\":\"Boyle\"}]}";
  2.  data=response.getJSON("data");
  3.  json_list = data.toJSONList();
  4.  id_list = List();
  5.  for each item in json_list
  6.  {
  7.     id_list.add(item.getJSON("id"));
  8.  }
  9.  info id_list;// Returns 1,2

toList

The toMap function takes a JSON formatted text as an argument, and returns a key-value pair.

Return Type

KEY-VALUE

Syntax

  1. <variable>=<json_text>.toMap();
where,

Examples

  1.  products = "{company:Zoho, product:Creator}";
  2.  info products.toMap(); // Returns the key-value pair {"product":"Creator","company":"Zoho"}

toLong

The toLong function takes an expression as an argument, and returns a number.

Return Type

NUMBER

Syntax

  1. <variable>=<expression>.toLong();
(OR)
  1. <variable>=toLong(<expression>);
(OR)
  1. <variable>=<expression>.toNumber();
(OR)
  1. <variable>=toNumber(<expression>);
where,

Examples

  1.  marks=99.9;
  2.  marks_text="100";

  3.  info toLong(marks);// Returns 99
  4.  info marks_text.toLong();// Returns 100

toMap

The toMap function takes a JSON formatted text as an argument, and returns a key-value pair.

Return Type

KEY-VALUE

Syntax

  1. <variable>=<json_text>.toMap();
where,

Examples

  1.  products = "{company:Zoho, product:Creator}";
  2.  info products.toMap(); // Returns the key-value pair {"product":"Creator","company":"Zoho"}

toNumber

The toLong function takes an expression as an argument, and returns a number.

Note:
  1. Decimals when subjected to the toNumber function will lose their fraction parts. Use toDecimal instead.
  2. If a piece of text has alphanumeric data(say, 1000abc) in it, then toNumber function will throw an error message.

Return Type

NUMBER

Syntax

  1. <variable>=<expression>.toNumber();
(OR)
  1. <variable>=toNumber(<expression>);
(OR)
  1. <variable>=<expression>.toLong();
(OR)
  1. <variable>=toLong(<expression>);
where,

Examples

  1.  decimal=123.25;
  2.  info decimal.toNumber();// Converts the decimal into a number and returns 123
  3.  num_text="1234";
  4.  info num_text.toNumber();// Returns 1234
  5.  alpha_text="134A123B";
  6.  info alpha_text.toNumber();// Returns error

toString

The toString function takes an expression as input and returns it as text.

Note:
  1. If the expression is of type date-time, you can specify two optional arguments, dateTimeFormat and timeZone, additionally. The function will return a DATE-TIME expression in the specified dateTimeFormat, converted into the specified time zone.
  2. If the expression is of type number (milliseconds), you can specify two optional arguments, dateTimeFormat and timeZone, additionally. The function will return a corresponding DATE-TIME expression in the specified dateTimeFormat, converted into the specified time zone. This is currently applicable to all Zoho services except Zoho Creator.
  3. In services other than Zoho Creator, you can either input expression of DATE-TIME datatype or a TEXT in date-time format in order for the dateTimeFormat and timeZoho parameters to take action. However, in Zoho Creator, the input should strictly be an expression of DATE-TIME datatype, inputting a TEXT value in date-time format will simply return the given value as-is.
  4. In Zoho Creator, if the function fails to recognize the date-time value, it will simply return the given value in text format. In other services, an error message will be displayed.
  5. We are working on unifying the differences in behavior between Zoho Creator and other services.

Return Type

TEXT

Syntax

  1. <variable>=<expression>.toString(<dateTimeFormat>,<timeZone>);
(OR)
  1. <variable>=toString(<expression>,<dateTimeFormat>,<timeZone>);
(OR)
  1. <variable>=<expression>.toText(<dateTimeFormat>,<timeZone>);
(OR)
  1. <variable>=toText(<expression>,<dateTimeFormat>,<timeZone>);
where,

Applicable Date-Time Literals


Examples

  1.  marks=100;
  2.  info toString(marks);// Returns "100"
  3.  marks=100;
  4.  info toString(marks);// Returns "100"
  5.  dateValue='01-Jan-2019 10:15:30';
  6.  info toString(dateValue,"MMM dd, yy 'at' hh:mm:ss, E","Europe/Moscow");// Returns "Jan 01, 19 at 07:45:30, Fri"
  7.  milliValue=1596719471334;
  8.  info toString(milliValue,"MMM dd, yy 'at' hh:mm:ss, E","Europe/Moscow");// Returns "Aug 06, 20 at 03:41:11, Thu"

toText

The toText function takes an expression, and returns it as text.

Note:
  1. If the expression is of type date-time or number (milliseconds), you can specify two optional arguments, dateTimeFormat and timeZone, additionally.
  2. The function will return the timestamp expression in the specified dateTimeFormat, converted into the specified timeZone.
  3. If the function fails to recognise the date-time value, it will simply return the given value in text format.

Return Type

TEXT

Syntax

  1. <variable>=<expression>.toText(<dateTimeFormat>,<timeZone>);
(OR)
  1. <variable>=toText(<expression>,<dateTimeFormat>,<timeZone>);
(OR)
  1. <variable>=<expression>.toString(<dateTimeFormat>,<timeZone>);
(OR)
  1. <variable>=toString(<expression>,<dateTimeFormat>,<timeZone>);
where,

Applicable Date-Time Literals


Examples

  1.  marks=100;
  2.  info toText(marks);// returns "100"
  3.  marks=100;
  4.  info toText(marks);// returns "100"
  5.  dateValue='01-Jan-2019 10:15:30';
  6.  info toText(dateValue,"MMM dd, yy 'at' hh:mm:ss, E","Europe/Moscow");// returns "Jan 01, 19 at 07:45:30, Fri"
  7.  milliValue=1596719471334;
  8.  info toText(milliValue,"MMM dd, yy 'at' hh:mm:ss, E","Europe/Moscow");// Returns "Aug 06, 20 at 03:41:11, Thu"

toTime

The toTime function takes expression, dateTimeMapping, and timeZone as arguments. It returns the expression (representing a date-time value) in the date-time format and (converted to) timezone as specified in application settings.

Note:
  1. Time zone specified in application settings is considered as the default time zone.
  2. The dateTimeMapping param is used to specify which values in the expression stand for which date time components.
  3. The timeZone param is used to denote the time zone in which the given date-time value (in the expression) falls in.

Return Type

DATE-TIME

Syntax

  1. <variable>=<expression>.toTime(<dateTimeMapping>,<timeZone>);
where,

Application Date-time literals


Examples

 //Assuming, date time format set in application settings is dd-MMM-yyyy and Time Zone set in application settings is Indian Standard Time (which is 2 hours and 30 minutes ahead of Moscow)
 dateTimeString="01,11,19 1:30:00 pm"; 
 info toTime(dateTimeString,"MM,d,yyyy hh:mm:ss a","Europe/Moscow");//returns 11-Jan-0019 16:00:00


    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








                                    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

                                                                                                      • Functions

                                                                                                        This guide helps you with the following: Create Functions  Normal Functions REST API Functions Invoke Functions  Edit Functions  Delete Functions Rest API Functions Authentication Version 2.0 Version 1.0 Example Comparison of Version 2.0 and 1.0 ...
                                                                                                      • Type check functions

                                                                                                        isDate The isDate() function takes an expression as an argument, and returns true if it is a valid date-time value. Otherwise, it returns false.     Return Type BOOLEAN Syntax <variable> = isDate(<expression> ); (or) <variable> = ...
                                                                                                      • Custom Functions

                                                                                                        The guide will help you with the following: Create Custom Functions Program Custom Functions  Test Custom Functions  Associate with Workflow Rules  Manage Custom Functions  Custom functions help in automation where procedural logic is required, which ...
                                                                                                      • Logical Functions

                                                                                                        The guide helps you with the following: 1. Difference between isBlank(), isNull() and isEmpty() functions 2. Equals 3. isBlank 4. isEmpty 5. isNull 6. isValidObject Difference between isBlank(), isNull() and isEmpty() functions The table below lists ...
                                                                                                      • Client Functions

                                                                                                        This guide will help you with the following: 1. Hide | Show 2. Enable | Disable 3. Add | Append 4. Select | Deselect 5. SelectAll | DeselectAll 6. Clear items 7. Alert  8. Reload 1. Hide | Show Overview The hide deluge task hides a specified field on ...
                                                                                                        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