here’s the sample code which returns the workflow casese which are not completed and were created before 2 days … you can adjust the filter based on the requirement
List pendingWorkfloCases = new ArrayList();
QueryOptions queryOptions = new QueryOptions();
queryOptions.addFilter(Filter.and(Filter.eq("complete",false),Filter.gt("created",Util.incrementDateByDays(new Date(), -2))));
Iterator wcItr = context.search(WorkflowCase.class,queryOptions);
while(wcItr.hasNext()){
WorkflowCase wc = wcItr.next();
pendingWorkfloCases.add(wc.getId());
}
return pendingWorkfloCases;