+ Start a Discussion
shiv kumar 48shiv kumar 48 

Events between to particular time

I have queried all the events in salesforce in a list now i want to loop through that list . if the startdate of event is between 12:00 AM to 1:00 PM i want to store in separate list ? how can i do it ?
Best Answer chosen by shiv kumar 48
Nithesh NNithesh N
Hi Shiv, Try this
List<Event> selectedEvents = new List<Event>();

for(Event e: allEvents) {
     DateTime startTime = e.StartDateTime;
     if((startTime.hour() >= 0) && (startTime.hour() <= 13)) {        

Please mark this solution as Best Solution to mark this forum as solved if it solves your question.