In this Salesforce tutorial, we will learn about the TODAY() function in Salesforce. This function returns the current date as a date data type from a date field. We can use the TODAY() function in Salesforce Lightning as well as Classic.
What is TODAY() function in Salesforce
In Salesforce, the TODAY() function is a date function that returns the current date according to the organization’s time zone. This function is commonly used in formula fields, validation rules, workflow rules, and other areas where date calculations or comparisons are needed. The output that we get from the TODAY() function is generally in Date format.
Syntax of TODAY() function in Salesforce
The syntax of the TODAY function is as follows:
TODAY()The TODAY() function does not take any parameters. It’s a zero-parameter function.
Considerations:
We should be aware of a few considerations while using the TODAY() function in Salesforce.
- The TODAY() function is dependent on the organization’s time zone settings, so it considers the date based on the organization’s time zone.
- The TODAY() function output always reflects the current date at the time of the evaluation of the formula or the validation rule.
How to use TODAY() function in Salesforce Lightning
In this example, we will use the TODAY() function to define a custom formula field that gives output as a number of days passed since contatct activation.
To use the TODAY() function in Salesforce Lightning, we will create a custom formula field using the Today function, and for that login to your developer account and follow the below steps.
1. To navigate to the Setup page of Lightning, click on the settings icon, and in the dropdown click on the Setup option.

2. On the Setup page of Salesforce Lightning, click on the Object Manager tab.

3. In the Object Manager window select the object to create a custom formula field. In this example, I have selected the object Contact.

4. In the Setup window of the object click on the Fields & Relationships in the left sidebar then click on the New button.

5. In this window, select the Formula data type and click on the Next button.

6. In this step, we will define the output of the formula field.
Enter the name for the Output field in the Field Label. In this example, I have named it as Days since activation and the Field Name will be auto-filled according to the entered field label.
Select the formula output type as Number and click on the Next button.

7. In this step, we will add a formula in the formula editor using the TODAY() function. Go to the Functions section on the right side of the window then select the TODAY function and click on the button Insert Selected Function.

8. After adding the TODAY() function in the formula editor add an operator “-“ and click on the button Insert Field.

9. In this window select a Date field and click on the Insert button. In this example, I have selected a custom Date field Activation Date.

10. Now the formula in the formula editor will be as follows:
TODAY() - Activatiom_date__cIn the above formula the TODAY() function will give the current date that will subtract the number of days from the Activation date and in output, we will get a number of days since the account is activated.
11. Now click on the button Check Syntax to validate the formula and if it does return any error then click on the Next button.

12. Select the profiles to give them access to this field and if you want to give access to all profiles then activate the Visible checkbox and click on the Next button.

13. In this step, activate the page to make this field visible in the selected page layouts. At last click on the Save button.

As we click on the Save button the formula field will be saved in the selected object and we will open a record from the object it will display the number of days according to the entered formula.

As we can view in the above image the output shows the number of days from the activation of the account.
In this way, we have successfully executed the TODAY function in Salesforce Lightning with the help of a custom formula field.
How to use TODAY() function in Salesforce Classic
In this example, we will check the status of the Case object in Salesforce Classic using the TODAY() function. This will help to provide real-time information on the task’s status by updating the “Case Status” field in the Case record based on the relationship between the due date and the current date.
In this example, we will use the TODAY() function in Salesforce Classic with the Formula field by adding TODAY() function in that formula.
1. On the Home page of Salesforce Classic, click on the Setup tab that is on the upper right side of the screen.
2. In the Setup page, go to the Build section on the left sidebar and click on the Customize dropdown.
In this dropdown click on Object name -> Fields.
In this example, I have selected the object Case to create a custom formula field.

3. In the setup page of the object scroll down to the section Custom Fields and Relationships and click on the New button.

4. In this step, select the Formula field type and click on the Next button.

5. In this window, define the Output of the formula field by entering the following fields.
Enter the name for the Output field in the Field Label. In this example, I have named it as Case Status and the Field Name will be auto-filled according to the entered field label.
Select the formula output type, and in this case output should be Text. After selecting output type click on the Next button.

6. To insert a formula in the formula editor we will require functions, and for that go to the Functions scroll bar on the left side of the window, select the TODAY function, and click on the button Insert Selected Function.
In the same way, you can also select other required functions.

7. According to the scenario explained at the beginning of the example we will define the formula in the formula editor with the help of the TODAY() function in the following way.
IF(Due_Date__c < TODAY(), "Overdue", IF(Due_Date__c = TODAY(), "Due Today", "Not Due"))We have defined the above formula with the help IF function, to create a conditional statement. Let’s understand the condition applied in the formula.
- IF(Due_Date__c < TODAY(), “Overdue”: This condition checks that if the Due Date (Due_Date__c) is less than the current date (TODAY()), the condition will be true and the output will be “Overdue”.
- IF(Due_Date__c = TODAY(), “Due Today”: This condition checks that if the Due Date (Due_Date__c) is equal to the current date (TODAY()), the condition will be true and the output will be “Due Today”.
- “Not Due”: If the above conditions are not True then the output will be “Not Due”.
8. After entering the formula in the formula editor click on the button Check Syntax to validate the formula and on successful validation click on the Next button.

9. In this step, we have to set the field-level security for the custom formula field, and for that, you can either select specific profiles or click on the Visible checkbox to make this field visible for all users.
After selecting the profiles click on the Next button.

10. In the last step, activate the page layouts to make this field visible on the object’s page layout. This field will be visible on the activated page layouts and after this click on the Save button.

As we click on the Save button the custom formula field will be saved in the Case object. Now to check the output of the formula applied in the formula field, open the record of the object, and there you can view the field Case Status that is returning the output according to the applied formula.

As we can view in the image the output is Not Due according to the applied condition in the formula above. Here the current date is 07/12/2023 which is less than 30/12/2023 hence the output is Not Due.
In this way, we have successfully executed the TODAY() function in Salesforce Classic by using it in a custom formula field.
Conclusion
In this Salesforce tutorial, we have learned about the use cases of the TODAY() function in Salesforce Lightning and Classic respectively, and with the help of a custom formula field we applied that displayed the output according to conditions that were true according to the formula.
Along with this, we also learned about the TODAY() function with its syntax and also came to know about the considerations that we should be aware of while using the TODAY() function in Salesforce.
You may like to read:
- Salesforce TIMEVALUE Function
- Salesforce TIMENOW Function
- Salesforce NOW Function
- Salesforce MONTH Function
- Salesforce ISNUMBER Function
I am Bijay Kumar, the founder of SalesforceFAQs.com. Having over 10 years of experience working in salesforce technologies for clients across the world (Canada, Australia, United States, United Kingdom, New Zealand, etc.). I am a certified salesforce administrator and expert with experience in developing salesforce applications and projects. My goal is to make it easy for people to learn and use salesforce technologies by providing simple and easy-to-understand solutions. Check out the complete profile on About us.