Date Literal | Range | Example |
---|---|---|
YESTERDAY | Starts 12:00:00 the day before and continues for 24 hours. | SELECT Id FROM Account WHERE CreatedDate = |
TODAY | Starts 12:00:00 of the current day and continues for 24 hours. | SELECT Id FROM Account WHERE CreatedDate > |
TOMORROW | Starts 12:00:00 after the current day and continues for 24 hours. | SELECT Id FROM Opportunity WHERE CloseDate = |
LAST_WEEK | Starts 12:00:00 on the first day of the week before the most recent first day of the week and continues for seven full days. First day of the week is determined by your locale. |
SELECT Id FROM Account WHERE CreatedDate > |
THIS_WEEK | Starts 12:00:00 on the most recent first day of the week before the current day and continues for seven full days. First day of the week is determined by your locale. |
SELECT Id FROM Account WHERE CreatedDate < |
NEXT_WEEK | Starts 12:00:00 on the most recent first day of the week after the current day and continues for seven full days. First day of the week is determined by your locale. |
SELECT Id FROM Opportunity WHERE CloseDate = |
LAST_MONTH | Starts 12:00:00 on the first day of the month before the current day and continues for all the days of that month. |
SELECT Id FROM Opportunity WHERE CloseDate > |
THIS_MONTH | Starts 12:00:00 on the first day of the month that the current day is in and continues for all the days of that month. |
SELECT Id FROM Account WHERE CreatedDate < |
NEXT_MONTH | Starts 12:00:00 on the first day of the month after the month that the current day is in and continues for all the days of that month. |
SELECT Id FROM Opportunity WHERE CloseDate = |
LAST_90_DAYS | Starts 12:00:00 of the current day and continues for the last 90 days. | SELECT Id FROM Account WHERE CreatedDate = |
NEXT_90_DAYS | Starts 12:00:00 of the current day and continues for the next 90 days. | SELECT Id FROM Opportunity WHERE CloseDate > |
LAST_N_DAYS:n | For the number n provided, starts 12:00:00 of the current day and continues for the last n days. | SELECT Id FROM Account WHERE CreatedDate = |
NEXT_N_DAYS:n | For the number n provided, starts 12:00:00 of the current day and continues for the next n days. | SELECT Id FROM Opportunity WHERE CloseDate > |
NEXT_N_WEEKS: n | For the number n provided, starts 12:00:00 of the first day of the next week and continues for the next n weeks. | SELECT Id FROM Opportunity WHERE CloseDate > |
LAST_N_WEEKS:n | For the number n provided, starts 12:00:00 of the last day of the previous week and continues for the last n weeks. | SELECT Id FROM Account WHERE CreatedDate = LAST_N_WEEKS:52 |
NEXT_N_MONTHS:n | For the number n provided, starts 12:00:00 of the first day of the next month and continues for the next n months. | SELECT Id FROM Opportunity WHERE CloseDate > |
LAST_N_MONTHS:n | For the number n provided, starts 12:00:00 of the last day of the previous month and continues for the last n months. | SELECT Id FROM Account WHERE CreatedDate = |
THIS_QUARTER | Starts 12:00:00 of the current quarter and continues to the end of the current quarter. |
SELECT Id FROM Account WHERE CreatedDate = |
LAST_QUARTER | Starts 12:00:00 of the previous quarter and continues to the end of that quarter. |
SELECT Id FROM Account WHERE CreatedDate > |
NEXT_QUARTER | Starts 12:00:00 of the next quarter and continues to the end of that quarter. |
SELECT Id FROM Account WHERE CreatedDate < |
NEXT_N_QUARTERS:n | Starts 12:00:00 of the next quarter and continues to the end of the nth quarter. | SELECT Id FROM Account WHERE CreatedDate < |
LAST_N_QUARTERS:n | Starts 12:00:00 of the previous quarter and continues to the end of the previous nth quarter. | SELECT Id FROM Account WHERE CreatedDate > |
THIS_YEAR | Starts 12:00:00 on January 1 of the current year and continues through the end of December 31 of the current year. |
SELECT Id FROM Opportunity WHERE CloseDate = |
LAST_YEAR | Starts 12:00:00 on January 1 of the previous year and continues through the end of December 31 of that year. |
SELECT Id FROM Opportunity WHERE CloseDate > |
NEXT_YEAR | Starts 12:00:00 on January 1 of the following year and continues through the end of December 31 of that year. |
SELECT Id FROM Opportunity WHERE CloseDate < |
NEXT_N_YEARS:n | Starts 12:00:00 on January 1 of the following year and continues through the end of December 31 of the nth year. | SELECT Id FROM Opportunity WHERE CloseDate < |
LAST_N_YEARS:n | Starts 12:00:00 on January 1 of the previous year and continues through the end of December 31 of the previous nth year. | SELECT Id FROM Opportunity WHERE CloseDate > |
THIS_FISCAL_QUARTER | Starts 12:00:00 on the first day of the current fiscal quarter and continues through the end of the last day of the fiscal quarter. The fiscal year is defined in the company profile under Setup at Company Profile | Fiscal Year. |
SELECT Id FROM Account WHERE CreatedDate = |
LAST_FISCAL_QUARTER | Starts 12:00:00 on the first day of the last fiscal quarter and continues through the end of the last day of that fiscal quarter. The fiscal year is defined in the company profile under Setup at Company Profile | Fiscal Year. |
SELECT Id FROM Account WHERE CreatedDate > |
NEXT_FISCAL_QUARTER | Starts 12:00:00 on the first day of the next fiscal quarter and continues through the end of the last day of that fiscal quarter. The fiscal year is defined in the company profile under Setup at Company Profile | Fiscal Year. |
SELECT Id FROM Account WHERE CreatedDate < |
NEXT_N_FISCAL_QUARTERS:n | Starts 12:00:00 on the first day of the next fiscal quarter and continues through the end of the last day of the nth fiscal quarter. The fiscal year is defined in the company profile under Setup atCompany Profile | Fiscal Year. | SELECT Id FROM Account WHERE CreatedDate < |
LAST_N_FISCAL_QUARTERS:n | Starts 12:00:00 on the first day of the last fiscal quarter and continues through the end of the last day of the previous nth fiscal quarter. The fiscal year is defined in the company profile under Setup at Company Profile | Fiscal Year. |
SELECT Id FROM Account WHERE CreatedDate > |
THIS_FISCAL_YEAR | Starts 12:00:00 on the first day of the current fiscal year and continues through the end of the last day of the fiscal year. The fiscal year is defined in the company profile under Setup at Company Profile | Fiscal Year. |
SELECT Id FROM Opportunity WHERE CloseDate = |
LAST_FISCAL_YEAR | Starts 12:00:00 on the first day of the last fiscal year and continues through the end of the last day of that fiscal year. The fiscal year is defined in the company profile under Setup at Company Profile | Fiscal Year. |
SELECT Id FROM Opportunity WHERE CloseDate > |
NEXT_FISCAL_YEAR | Starts 12:00:00 on the first day of the next fiscal year and continues through the end of the last day of that fiscal year. The fiscal year is defined in the company profile under Setup at Company Profile | Fiscal Year. |
SELECT Id FROM Opportunity WHERE CloseDate < |
NEXT_N_FISCAL_YEARS:n | Starts 12:00:00 on the first day of the next fiscal year and continues through the end of the last day of the nth fiscal year. The fiscal year is defined in the company profile under Setup at Company Profile | Fiscal Year. |
SELECT Id FROM Opportunity WHERE CloseDate < |
LAST_N_FISCAL_YEARS:n | Starts 12:00:00 on the first day of the last fiscal year and continues through the end of the last day of the previous nth fiscal year. The fiscal year is defined in the company profile under Setup at Company Profile | Fiscal Year. |
SELECT Id FROM Opportunity WHERE CloseDate > |
Date Literals in Salesforce SOQL
Biswajeet
June 6, 2015 No Comments on Date Literals in Salesforce SOQL