Salesforce Fact #632 | WEEK_IN_MONTH() in SOQL

Suppose we need to find out the number of account records created grouped by the week in the month. We can use the WEEK_IN_MONTH() function in SOQL for this:

SELECT WEEK_IN_MONTH(CreatedDate), Count(Id) FROM Account WHERE CreatedDate = THIS_MONTH GROUP BY WEEK_IN_MONTH(CreatedDate)  

Reference: https://developer.salesforce.com/docs/atlas.en-us.soql_sosl.meta/soql_sosl/sforce_api_calls_soql_select_date_functions.htm

Comments

Popular posts from this blog

Salesforce Fact #192 | Call batch apex from flow

Salesforce Fact #457 | Get current user role name in flow