Event e = new Event();
e.ActivityDate = Date.newInstance(2005,05,25);
insert e; //inserting an event record with all the required fields.
//The below 4 lines are just to check if am doing it as expected.
Date d1 = Date.newInstance(2005,05,05); //Same date in query.
Date d2 = Date.newInstance(2005,06,05); //Same date in query.
Boolean b1 = e.ActivityDate > d1; //This is true
Boolean b2 = e.ActivityDate < d2; //This is true
List<Event> myList = [SELECT id, ActivityDate FROM Event WHERE ActivityDate > 2005-05-05 AND ActivityDate < 2005-06-05];
System.assertEquals(1,myList.size()); //System.AssertException: Assertion Failed: Expected: 1, Actual: 0
The main goal is to filter a few records based on the dates but it won't return any records. The ActivityDate < 2005-06-05
is working fine in the query but not the first part.
//good
List<Event> myList = [SELECT id, ActivityDate FROM Event WHERE ActivityDate < 2005-06-05];
System.assertEquals(1,myList.size()); //true
//bad
List<Event> myList = [SELECT id, ActivityDate FROM Event WHERE ActivityDate > 2005-05-05];
System.assertEquals(1,myList.size()); //System.AssertException: Assertion Failed: Expected: 1, Actual: 0
I should be missing something very silly. Please advice, thank you.
WHERE ActivityDate > 2005-05-05