Salesforce Fact #352 | CALENDAR_QUARTER() in SOQL
Do you know we have a CALENDAR_QUARTER() function in SOQL. It returns the values 1, 2, 3 and 4 for the date value ranges 1st Jan - 31st Mar, 1st Apr - 30th Jun, 1st July - 30th Sep and 1st Oct - 31st Dec respectively.
Suppose, we need to find out the no. of account records created in each of the quarter. We can use GROUP BY on the quarter value using the below SOQL:
SELECT CALENDAR_QUARTER(CreatedDate), Count(Id) FROM Account GROUP BY CALENDAR_QUARTER(CreatedDate)
Comments
Post a Comment