salesforceapex-codesalesforce-lightningsoqlsalesforce-service-cloud

How To Amend This SOQL to get All records for today After 6am


Is there a way I can customize this SOQL query to include all records after 6am from Today?

SELECT Case__c, Level_1__c, Level_2__c,Level_3__c 
   FROM Case_Type__c  
   WHERE createddate = today 
   GROUP BY Case__c,Level_1__c, Level_2__c,Level_3__c

I need to do this within the SOQL query.


Solution

  • Use HOUR_IN_DAY() from date functions

    Something like:

    WHERE CreatedDate = today AND HOUR_IN_DAY(CreatedDate) > 5