Date functions in SOQL queries allow you to group or filter data by date periods such as day, calendar month, or fiscal year.
例:
SELECT CALENDAR_YEAR(CreatedDate), SUM(Amount)
FROM Opportunity
GROUP BY CALENDAR_YEAR(CreatedDate)
SELECT CreatedDate, Amount
FROM Opportunity
WHERE CALENDAR_YEAR(CreatedDate) = 2009
CALENDAR_MONTH()
CALENDAR_QUARTER()
CALENDAR_YEAR()
DAY_IN_MONTH()
DAY_IN_WEEK()
DAY_IN_YEAR()
DAY_ONLY()→Returns a date representing the day portion of a dateTime field.
FISCAL_MONTH()
FISCAL_QUARTER()
FISCAL_YEAR()
→This function is not supported if your organization has custom fiscal years enabled. See "Define Your Fiscal Year" in the Salesforce Help.
HOUR_IN_DAY()→Returns a number representing the hour in the day for a dateTime field.
WEEK_IN_MONTH()
WEEK_IN_YEAR()