How to Create Date Time Formula Field in Zoho CRM
Permission Required
Users with the Field-level Access permission in profile can access this feature.
The following table helps you to understand the type of arguments required for DateTime functions along with the type of syntax that needs to be formed.
| Newdate | Creates a date from the year, month, day and time. | Newdate(year,month,day, hour,minute,'string') | Newdate(2007,12,21,06,30,'AM') returns quot;21/12/2007 06:30 AM"1 |
| Datepart | Returns the date value for the date time expression. | Datepart(datetime argument) | Datepart(Newdate(2007,12,21,06,30,'AM')) returns "21/12/2007"1 |
| Timepart | Returns the time value for the date time expression. | Timepart(datetime argument) | Timepart(Newdate(2007,12,21,06,30,'AM')) returns "06.30 AM" |
| Adddate | Returns the date obtained by adding n (year/day/month/hour/min) to the given date. | Adddate(datetime,number, 'string') | Adddate(Newdate(2007,12,21,06,30,'AM'),2,'YEAR' returns "21/12/2009 06:30 AM"2 |
| Subdate | Returns the date obtained by subtracting n (year/day/month/hour/min) to the given date. | Subdate(datetime,number, 'string') | Subdate (Newdate(2007,12,21,06,30,'AM'),2,'YEAR' returns "21/12/2005 06:30 AM"2 |
| Now | Returns a date/time representing the current moment. | Now() | Now() returns "19/05/2009 10:52 AM" |
| Datecomp | Compares two dates and returns the difference of days in minutes. | Datecomp(Datetime, Datetime) | Datecomp(Newdate(2009,05,19,11,30,'AM'), Newdate(2009,05,19,12,30,'AM')) returns 660.0 3 |
| Dayofmonth | Returns the day of the month for the given date. | Dayofmonth(Datetime) | Dayofmonth(Newdate(2009,05,19,11,30,'AM')) returns "19.0" |
| Hour | Returns the hour corresponding to the given date. | Hour(Datetime) | Hour(Newdate(2009,05,19,11,30,'AM')) returns "11.0" |
| Minute | Returns the minute corresponding to the given date. | Minute(Datetime) | Minute(Newdate(2009,05,19,11,30,'AM')) returns "30.0" |
| Month | Returns the month corresponding to the given date. | Month(Datetime) | Month(Newdate(2009,05,19,11,30,'AM')) returns "5.0" |
| Year | Returns the year corresponding to the given date | Year(Datetime) | Year(Newdate(2009,05,19,11,30,'AM')) returns "2009.0" |
| Weekday | Returns the day of the week (1-7) corresponding to the input date, where 1 is Sunday, 2 is Monday and so on. | Weekday(Datetime) | Weekday(Newdate(2009,05,19,11,30,'AM')) returns "3.0". (This is because 19th May is Tuesday)4 |
| Dayofweek | Returns the day of the week for the given date. | Dayofweek(date-time) | April 5th 2023 returns "wednesday" |
| Dayofmonth | Returns the number corresponding to the day of the month for the given date. | Dayofmonth(date-time) | April 5th returns '5' |
| Dayofyear | Returns the number corresponding to day of the year for the given date. | Dayofyear(date-time) | April 5th 2023 returns "95" |
| Timestamp | Returns timestamp of the value | Timestamp(date-time) | Timestamp(Newdate(2022,02,10,11,30,'AM')) gives result as 1,171,107,000 |
- The input DateTime argument format should always be YYYY,MM,DD,HH,MM,AM/PM but the output will be displayed as per the selected Country Locale.
- The string data type (YEAR/DAY/MONTH/HOUR/MINUTE) should be in UPPERCASE.
- The resulting return value for the Datecomp function is always displayed in minutes.
- If the date value is “0” the function returns null.
- Log in to Zoho CRM with Administrator privileges.
- Go to Setup > Customization > Modules and Fields. Module refers to the Leads, Accounts, Contacts, etc. tabs.
- Click the required module. The Layout Editor opens.
- Drag and drop the Formula field from the New Fields tray to the required module section on the right.
- In the Formula Properties window, do the following:
- Enter id in the Label field.
- Select DateTime as the Formula Return Type from the drop-down list.
-
Constructing Formulas
- Under Select Functions, select DateTime Functions from the drop-down list.
- From the list of DateTime Functions, choose a function and click Insert. (Alternatively, you can double-click on a function to insert)
- In the Formula expression, click between the parenthesis to insert an argument.
- Under Select Field column, choose a field and click Insert. (Alternatively, you can double-click on a field to insert)
- Under Select Operator column, choose an operator and click Insert.
- Click Check Syntax to check the construction of the formula.
- Click Save.
Note: To ensure accuracy and timeliness of the duration, kindly refresh the record manually before you subject the formula field’s value to your processes.
If you would like for the formula field to run at all times, then select the Automatically refresh formula fields containing the Now function in real-time checkbox under the syntax.
Tip: The checkbox is used to render current values. To calculate the imminent times—say, the number of days, or the number of hours passed by—this checkbox will be beneficial as the next visiting day will display the real time value. If your calculation requires returning values in terms of years, then the values may not visually be ticking each day, and relying on the edit-based value update could save your limits.
Notes and Limitations:
- This checkbox will appear only for formulas with the Now function in it.
- If you have opted to auto-refresh the formula field, then the result rendered will always be current and valid—even while viewing the record.
- This auto-refresh property can be applied only for two formula fields
owing to technical limitations. - If you have enabled auto-refresh and you cannot build complex expressions—you will end up with this error:
- In general, a formula field created in one layout can be utilized from the unused fields tray, and the expression can be modified per the need of the current layout. If you have enabled auto-refresh in one layout, then modifying in another layout will make that change reflect in all of the layouts.
- Limitations on timeline with regards to auto-refresh enabled fields:
- The auto-refreshing of fields is not considered as record edit or record update and hence the record timeline nor audit log will capture these refreshes as logs.
- If there is an edit made to the record—either manually or via automation—the formula field will also be refreshed owing to the record edit, and the timeline or audit log will show just the recent value changed. The previous value from which the formula got updated will not be shown.
For example: If a formula value was 5, and upon editing it ascended to 7, then the log shows only the formula field is updated to 7.
- Limitations on search behavior: When a global search is made and the resultant record has auto-refresh fields enabled, then the result will behave as follows:
- Only the older field value can be searched.
- In the result page of the global search, the resultant records will be listed categorically based on modules, and you can manage their column labels. Fields enabled with the auto-refresh property will not be available under these manage column toggles.
- For the approval process:
If the approval process is created based on a formula field with auto-refresh enabled, then when the record meets the criteria, it will be queued under My jobs tab. If the formula is day- or hour-based, the record upon viewing will show a different value inside the record. This will cause misinterpretation of the approval process for inaccuracy, as the automation will be triggered when the record qualifies, and owing to the auto-refresh property, the actual result might be different. - For Workflow rules:
- As auto-refresh fields aren’t necessarily record updates, the fields listed in the list of triggers when date/time-based triggers will not have the auto-enabled date/time returning formula field.
- The same applies for field updates. A field’s auto refresh is not considered record edits to trigger an automation built based on field updates.
- The auto-refreshed field values aren’t necessarily record updates to trigger workflows based on field updates.
- The auto-refresh enabled fields will not trigger any automations. However, if a condition (criteria) is built based on the formula field, then the workflow will be executed.
- For custom view and Advanced filter: The auto-refresh enabled fields are not supported in custom view criteria.
- If used in Advanced filter, though the auto-refresh field will render results, the filter criteria cannot be saved as a saved filter.
- You cannot use these fields as part of Query component in Wizards.
- If a formula used in a custom view and query component before enabling auto-refresh, then enabling this property will exclude the field from the configuration.
- The NewDate function cannot be used in expression of formulas that are set to Auto-refresh.
- When you try to use fields to compose expressions for an auto-refresh formula, you cannot use Multiline, lookup, or picklist fields.
- Looking up a field (using field of lookup) with auto-refresh property is not possible.
- Auto-refresh fields can be used as columns in List view and updated values are only displayed.
- This field is restricted for use by features powered by Zia and in ABM for Zoho CRM.
- Reports and analytics inherently refresh once a day. If your formula is set to auto-refresh based on hour or on days, the auto-refresh of the reports or analytics might not be synched and may reflect the old value. We recommend you to refresh your report before you consider for evaluation.
- Encrypted fields cannot be auto-refreshed. Also, fields participating in auto-refresh cannot be encrypted.
- Fields with auto-refresh cannot be used in rollup summary calculations.
- In the following features, you can use only two auto-refresh fields as part of their criteria editor:
- Data sharing rule
- Scoring rule
- Lookup filter
- Motivator
- CPQ(Product configurator and price rules)
- Smart filter
- Record locking rule filter
- Report
- Analytics
- Territory
- Mass tools
- Find and Merge
- The following functions are not supported
Imagine this banking example. Zylker bank has an educational savings scheme for kids and teens from age 0 to the year 18. The applicant, upon turning 18, will have the account type converted to a regular banking account, and the amount saved thus far will be deposited with interest to the account itself.
To view the age of the applicant, Zylker can use a formula with the Now function in it. This is the syntax: DateComp(DOB,Now())/(60*24*365). Say, the applicant is 9 years old, then this formula will render the value 9.
If you’d like to stop this time-based computation based on an event, then you can choose to Specify a condition to stop the formula value update. If you check this checkbox, a formula workspace opens up for you to provide the syntax of the conditions. If a record met the specified condition, then the formula field will stop the timer at that instance and render the latest value.
For example, to assess the number of days a prospect spent using the trial version of a software, the business should have an action that marks the end of the trial—say purchasing. Here, the date of purchase or purchase status, or invoice created date act as resultant action to mark the end of the trial. Let’s replicate this using our Stop formula with a condition property.
The minute the Date of purchase is populated indicating the ascension of the contact’s subscription, the formula stops its computation.
Now, let us understand them both in action.
Closing a deal is an important milestone for each business and the time to close is a vital KPI that businesses monitor as the longer it goes, the lower are the chances to win the deal. That being said, let’s look at how we can build a formula to calculate the time taken to close a deal.
This is a two-phased approach: 1. Run a formula until closure, 2. Stop the formula once it is closed.
Per the above properties, the formula will keep refreshing automatically, and whenever the record is viewed, based on the auto-refresh on the now function in the expression, the formula will display the current value. Also, if the Probability of the deal hits 100%, the formula will stop computing, rendering the value for time to close.