How can I check if a Date field is empty or blank? I tried this statement:


But I don't get the desired result, even if I delete the date value, it still does not go inside the if statement.

This is the Debug Log:

USER_DEBUG|[138]|DEBUG|*** Current_Launch_Date__c: 2017-04-03 00:00:00

  • 1
    What is the data type of Current_Launch_Date__c? because every variable in apex is assigned null by default. So ideally if(project.Current_Launch_Date__c==null) this should work. – Rohit Mourya Apr 3 '17 at 11:09
  • the data type is Date – Json Apr 3 '17 at 11:15
  • Then if(project.Current_Launch_Date__c==null) is correct. Try adding System.debug(project.Current_Launch_Date__c) before if and check the value of project.Current_Launch_Date__c. It must be having some value in it. – Rohit Mourya Apr 3 '17 at 11:17
  • can you share your complete code or any debug logs related to this ? – Vamsi Krishna Apr 3 '17 at 11:18
  • 1
    Check if a workflow or a process is setting the date - it's clearly setting the date to today's date. – Caspar Harmer Apr 3 '17 at 18:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.