Relative Dates in Salesforce

This article is about the Relative Dates explains them in more detail, but the short version is that instead of using a specific date like 4/1/2019, you can use a “relative” date like “TODAY”, “NEXT WEEK”, “LAST QUARTER”, and so on. You can immediately see how these are useful in reports, because you can simply plug in a relative date filter and your report is always current. Capitalization doesn’t matter in relative date filter operators. “THIS YEAR” works, as do “This Year” and “this year.”

1. Relative Dates in List Views

To add a relative date filter criteria to any of your existing list views. Take a look at this Opportunity List View with the criteria of “CLOSE DATE EQUALS NEXT MONTH” added. Anywhere your users have list views that use some sort of date-based criteria, make sure they know about relative dates.

screenshot of Salesforce with Opportunities Closing Next Month list view

2. Relative Dates in Reports

You probably saw this one coming, as this is the next obvious use case. Below is an example of the same set of Opportunities, but shown in a report rather than a List View. And if you want to just filter on “Year to Date,” don’t worry, you just need to have 2 filters: “DATE EQUALS THIS YEAR” and “DATE LESS THAN OR EQUAL TO TODAY.” More information is in this help article.

Salesforce screenshot of Next Month's Open Deals with Relative Dates shown

3. Relative Dates in Dashboard Filters

Another great use case for Relative Dates is on a Dashboard, specifically within a Dashboard Filter. If you’re not using Dashboard Filters already, definitely take a look at them. They can be extremely handy for keeping your dashboard relevant to people looking at it. Sunshine Sales Dashboard showing relative dates

4. Relative Dates in Macros

This is a little different from the date filters above. Relative dates here allow you to create tasks which are dated relative to today’s date, time, or date and time.

screenshot of relative dates in Macro Builder

5. Relative Dates in Process Builder

Finally, you can also use Relative Dates within your Process Builder Criteria with a little help from our friend Formula Builder.  Here is an example of a Task that is created when an Opportunity Closes, and the Due Date is set to a formula: “TODAY() + 7” which is a week after the opp stage changes to Closed Won. Here is a release notes article with more information about how to use this.

screenshot of relative dates in Process Builder

 

Here is the list of different relative Date values in salesforce….

RELATIVE DATE VALUE RANGE
YESTERDAY Starts at 12:00:00 AM on the day before the current day and continues for 24 hours.
TODAY Starts at 12:00:00 AM on the current day and continues for 24 hours.
TOMORROW Starts at 12:00:00 AM. on the day after the current day and continues for 24 hours.
LAST WEEK Starts at 12:00:00 AM on the first day of the week before the current week and continues for seven days.
THIS WEEK Starts at 12:00:00 AM on the first day of the current week and continues for seven days.
NEXT WEEK Starts at 12:00:00 AM on the first day of the week after the current week and continues for seven days.
LAST n WEEKS Starts at 12:00:00 AM on the first day of the week that started n weeks before the current week, and continues up to 11:59 PM on the last day of the week before the current week.
NEXT n WEEKS Starts at 12:00:00 AM on the first day of the week after the current week and continues for n times seven days.
n WEEKS AGO Starts at 12:00:00 AM on the first day of the week that started n weeks before the start of the current week and continues for seven days.
LAST MONTH Starts at 12:00:00 AM on the first day of the month before the current month and continues for all the days of that month.
THIS MONTH Starts at 12:00:00 AM on the first day of the current month and continues for all the days of that month.
NEXT n MONTHS Starts at 12:00:00 AM on the first day of the month after the current month and continues until the end of the nth month.
LAST n MONTHS Starts at 12:00:00 AM on the first day of the month that started nmonths before the current month and continues up to 11:59 PM on the last day of the month before the current month.
n MONTHS AGO Starts at 12:00:00 AM on the first day of the month that started nmonths before the start of the current month and continues for all the days of that month.
NEXT MONTH Starts at 12:00:00 AM on the first day of the month after the current month and continues for all the days of that month.
LAST 90 DAYS Starts at 12:00:00 AM 90 days before the current day and continues up to the current second. (The range includes today.)
NEXT 90 DAYS For standard date filters, starts at 12:00:00 AM on the day that the report is run and continues for 90 days. (The range includes today.)

For custom field filters, starts at 12:00:00 AM on the day after the current day and continues for 90 days. (The range does not include today.)

LAST n DAYS Starts at 12:00:00 AM n days before the current day and continues up to the current second. (The range includes today. Using this date value includes records from n + 1 days ago up to the current day.)
NEXT n DAYS For standard date filters, starts at 12:00:00 AM on the day that the report is run and continues for n days. (The range includes today.)

For custom field filters, starts at 12:00:00 AM on the next day and continues for the next n days. (The range does not include today.)

n DAYS AGO Starts at 12:00:00 AM on the day n days before the current day and continues for 24 hours. (The range does not include today.)
LAST QUARTER Starts at 12:00:00 AM on the first day of the calendar quarter before the current calendar quarter and continues to the end of that quarter.
THIS QUARTER Starts at 12:00:00 AM on the first day of the current calendar quarter and continues to the end of the quarter.
NEXT QUARTER Starts at 12:00:00 AM on the first day of the calendar quarter after the current calendar quarter and continues to the end of that quarter.
LAST n QUARTERS Starts at 12:00:00 AM on the first day of the calendar quarter nquarters ago and continues to the end of the calendar quarter before the current quarter. (The range does not include the current quarter.)
NEXT n QUARTERS Starts at 12:00:00 AM on the first day of the calendar quarter after the current quarter and continues to the end of the calendar quarter nquarters in the future. (The range does not include the current quarter.)
n QUARTERS AGO Starts at 12:00:00 AM on the first day of the calendar quarter nquarters before the current calendar quarter and continues to the end of that quarter.
LAST YEAR Starts at 12:00:00 AM on January 1 of the year before the current year and continues through the end of December 31 of that year.
THIS YEAR Starts at 12:00:00 AM on January 1 of the current year and continues through the end of December 31 of the current year.
NEXT YEAR Starts at 12:00:00 AM on January 1 of the year after the current year and continues through the end of December 31 of that year.
n YEARS AGO Starts at 12:00:00 AM on January 1 of the calendar year n years before the current calendar year and continues through the end of December 31 of that year.
LAST n YEARS Starts at 12:00:00 am on January 1, n+1 years ago. The range ends on December 31 of the year before the current year.
NEXT n YEARS Starts at 12:00:00 AM on January 1 of the year after the current year and continues through the end of December 31 of the nth year.
LAST FISCAL QUARTER Starts at 12:00:00 AM on the first day of the fiscal quarter before the current fiscal quarter and continues through the last day of that fiscal quarter. The fiscal quarter is defined on the Fiscal Year page in Setup.

NOTE None of the FISCAL literal date values are supported when creating mobile custom views.
THIS FISCAL QUARTER Starts at 12:00:00 AM on the first day of the current fiscal quarter and continues through the end of the last day of the current fiscal quarter. The fiscal quarter is defined on the Fiscal Year page in Setup.
NEXT FISCAL QUARTER Starts at 12:00:00 AM on the first day of the fiscal quarter after the current fiscal quarter and continues through the last day of that fiscal quarter. (The range does not include the current quarter.) The fiscal quarter is defined on the Fiscal Year page in Setup.
LAST n FISCAL QUARTERS Starts at 12:00:00 AM on the first day of the fiscal quarter n fiscal quarters ago and continues through the end of the last day of the previous fiscal quarter. (The range does not include the current fiscal quarter.) The fiscal quarter is defined on the Fiscal Year page in Setup.
NEXT n FISCAL QUARTERS Starts at 12:00:00 AM on the first day of the fiscal quarter after the current fiscal quarter and continues through the end of the last day of the nth fiscal quarter. (The range does not include the current fiscal quarter.) The fiscal quarter is defined on the Fiscal Year page in Setup.
n FISCAL QUARTERS AGO Starts at 12:00:00 AM on the first day of the fiscal quarter n fiscal quarters before the current fiscal quarter and continues through the end of the last day of that fiscal quarter.
LAST FISCAL YEAR Starts at 12:00:00 AM on the first day of the fiscal year before the current fiscal year and continues through the end of the last day of that fiscal year. The fiscal quarter is defined on the Fiscal Year page in Setup.
THIS FISCAL YEAR Starts at 12:00:00 AM on the first day of the current fiscal year and continues through the end of the last day of the fiscal year. The fiscal quarter is defined on the Fiscal Year page in Setup.
NEXT FISCAL YEAR Starts at 12:00:00 AM on the first day of the fiscal year after the current fiscal year and continues through the end of the last day of that fiscal year. The fiscal quarter is defined on the Fiscal Year page in Setup.
LAST n FISCAL YEARS Starts at 12:00:00 AM on the first day of the fiscal year n fiscal years ago and continues through the end of the last day of the fiscal year before the current fiscal year. (The range does not include the current fiscal year.) The fiscal quarter is defined on the Fiscal Year page in Setup.
NEXT n FISCAL YEARS Starts at 12:00:00 AM on the first day of the fiscal year after the current fiscal year and continues through the end of the last day of the nth fiscal year. (The range does not include the current fiscal year.) The fiscal quarter is defined on the Fiscal Year page in Setup.
n FISCAL YEARS AGO Starts at 12:00:00 AM on the first day of the fiscal year n fiscal years ago and continues through the end of the last day of that fiscal year.

 

Ref: https://admin.salesforce.com/

Thanks

Jayakrishna

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s