Pages

Wednesday, February 26, 2014

Query Date Field in Salesforce using SOQL

Looking record for Blank Date
In report, we can easily add filter date equals <blank> , leave the value empty


In validation rule or workflow rule, we can use ISBLANK() formula to check if the date field is blank, example: ISBLANK( default_date__c )

To run SOQL query for records with blank date
example: SELECT Id, Name FROM Account WHERE default_date__c = NULL


Compare with a date
example: SELECT Id, Name, default_date__c From Account WHERE default_date__c > 2014-01-15 ORDER BY default_date__c 

Note: it have to be in YYYY-MM-DD (need to be 4-2-2 characters, so 2014-1-15 will not works)


Reference: