I use an apex method that takes as inputs 2 dates. And i query on events and then i return the list of events. My code is this:
@AuraEnabled
public static List<Event> getEventsForDateRange(String fromDate, String endDate){
try{
date date1 = date.valueOf(fromDate);
date date2 = date.valueOf(endDate);
List<Event> eventsList = [select id, Subject, OwnerId, StartDateTime, EndDateTime, Street__c, City__c, Country__c, Postal_Code__c from Event
where ownerId =: UserInfo.getUserId() AND StartDateTime >: date1 AND StartDateTime <=: date2];
return eventsList;
} catch(Exception e) {
throw new AuraHandledException('Error! ' +e.getMessage());
}
}
But i give as inputs:fromDate 2020-04-08 and endDate 2020-04-09. And despite the fact that i have events in 09/04/2020 and the owner is my user, the method returns an empty list... Could anyone explain me what i am doing wrong? This is the system.debug that i run in my anonymous console
system.debug(fullCalendarController.getEventsForDateRange('2020-04-08','2020-04-09'));