SHARE
TWEET

Untitled

a guest Jun 26th, 2019 60 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Event e = new Event();
  2. e.ActivityDate = Date.newInstance(2005,05,25);
  3. insert e; //inserting an event record with all the required fields.
  4.  
  5. //The below 4 lines are just to check if am doing it as expected.
  6. Date d1 = Date.newInstance(2005,05,05); //Same date in query.
  7. Date d2 = Date.newInstance(2005,06,05); //Same date in query.
  8. Boolean b1 = e.ActivityDate > d1; //This is true
  9. Boolean b2 = e.ActivityDate < d2; //This is true
  10.  
  11. List<Event> myList = [SELECT id, ActivityDate FROM Event WHERE ActivityDate > 2005-05-05 AND ActivityDate < 2005-06-05];
  12. System.assertEquals(1,myList.size()); //System.AssertException: Assertion Failed: Expected: 1, Actual: 0
  13.      
  14. //good
  15. List<Event> myList = [SELECT id, ActivityDate FROM Event WHERE ActivityDate < 2005-06-05];
  16. System.assertEquals(1,myList.size()); //true
  17.  
  18. //bad
  19. List<Event> myList = [SELECT id, ActivityDate FROM Event WHERE ActivityDate > 2005-05-05];
  20. System.assertEquals(1,myList.size()); //System.AssertException: Assertion Failed: Expected: 1, Actual: 0
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top