Notes
YESTERDAY
SELECT Id, Name FROM Account WHERE CreatedDate = YESTERDAY
RANGE
Starts at 12:00:00 AM on the day before the current day and continues for 24 hours.
TODAY
SELECT Id, Name FROM Account WHERE CreatedDate = TODAY
Starts at 12:00:00 AM on the current day and continues for 24 hours.
TOMORROW
SELECT Id, Name FROM Opportunity WHERE CloseDate = TOMORROW
Starts at 12:00:00 AM. on the day after the current day and continues for 24 hours.
LAST WEEK
SELECT Id, Name FROM Opportunity WHERE CloseDate = 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
SELECT Id, Name FROM Opportunity WHERE CloseDate = THIS_WEEK
Starts at 12:00:00 AM on the first day of the current week and continues for seven days.
NEXT WEEK
SELECT Id, Name FROM Opportunity WHERE CloseDate = 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
SELECT Id, Name FROM Opportunity WHERE CloseDate= LAST_n_WEEKS:4
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
SELECT Id, Name FROM Opportunity WHERE CloseDate= NEXT_n_WEEKS:2
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
SELECT Id, Name FROM Opportunity WHERE CloseDate= n_WEEKS_AGO:2
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
SELECT Id, Name FROM Opportunity WHERE CloseDate= LAST_WEEK
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
SELECT Id, Name FROM Opportunity WHERE CloseDate= 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
SELECT Id, Name FROM Opportunity WHERE CloseDate= NEXT_n_MONTHS:2
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
SELECT Id, Name FROM Opportunity WHERE CloseDate= LAST_n_MONTHS:2
Starts at 12:00:00 AM on the first day of the month that started n months 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
SELECT Id, Name FROM Opportunity WHERE CloseDate= n_MONTHS_AGO:2
Starts at 12:00:00 AM on the first day of the month that started n months before the start of the current month and continues for all the days of that month.
NEXT MONTH
SELECT Id, Name FROM Opportunity WHERE CloseDate= 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 n DAYS
SELECT Id, Name FROM Opportunity WHERE CloseDate= LAST_n_DAYS:3
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.) In standard filters, n can be 7, 30, 60, 90, or 120.
NEXT n DAYS
SELECT Id, Name FROM Opportunity WHERE CloseDate= NEXT_n_DAYS:3
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.) In standard filters, n can be 7, 30, 60, 90, or 120.
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
SELECT Id, Name FROM Opportunity WHERE CloseDate= n_DAYS_AGO:12
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
SELECT Id, Name FROM Opportunity WHERE CloseDate= 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
SELECT Id, Name FROM Opportunity WHERE CloseDate= 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
SELECT Id, Name FROM Opportunity WHERE CloseDate= 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
SELECT Id, Name FROM Opportunity WHERE CloseDate= LAST_n_QUARTERS:2
Starts at 12:00:00 AM on the first day of the calendar quarter n quarters 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
SELECT Id, Name FROM Opportunity WHERE CloseDate= NEXT_n_QUARTERS:2
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 n quarters in the future. (The range does not include the current quarter.)
n QUARTERS AGO
SELECT Id, Name FROM Opportunity WHERE CloseDate= n_QUARTERS_AGO:3
Starts at 12:00:00 AM on the first day of the calendar quarter n quarters before the current calendar quarter and continues to the end of that quarter.
LAST YEAR
SELECT Id, Name FROM Opportunity WHERE CloseDate= 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
SELECT Id, Name FROM Opportunity WHERE CloseDate= 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
SELECT Id, Name FROM Opportunity WHERE CloseDate= 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
SELECT Id, Name FROM Opportunity WHERE CloseDate= LAST_n_YEARS:5
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
SELECT Id, Name FROM Opportunity WHERE CloseDate= NEXT_n_YEARS:5
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
SELECT Id, Name FROM Opportunity WHERE CloseDate= 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.
THIS FISCAL QUARTER
SELECT Id, Name FROM Opportunity WHERE CloseDate= 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
SELECT Id, Name FROM Opportunity WHERE CloseDate= 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
SELECT Id, Name FROM Opportunity WHERE CloseDate= LAST_n_FISCAL_QUARTERS:2
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
SELECT Id, Name FROM Opportunity WHERE CloseDate= NEXT_n_FISCAL_QUARTERS:2
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
SELECT Id, Name FROM Opportunity WHERE CloseDate= n_FISCAL_QUARTERS_AGO:2
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
SELECT Id, Name FROM Opportunity WHERE CloseDate= 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
SELECT Id, Name FROM Opportunity WHERE CloseDate= 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
SELECT Id, Name FROM Opportunity WHERE CloseDate= 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
SELECT Id, Name FROM Opportunity WHERE CloseDate= LAST_n_FISCAL_YEARS:2
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
SELECT Id, Name FROM Opportunity WHERE CloseDate= NEXT_n_FISCAL_YEARS:2
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
SELECT Id, Name FROM Opportunity WHERE CloseDate= LAST_n_FISCAL_YEARS:2
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.