Trading network to retrieve failed tasks within date range using custom flow service / java service

Hi All,
Need help on the following topic:-
How can i retrieve failed tasks from Trading Network within date range using custom flow service / java service.

Thanks