Historic Process Instance Date Range Query

Hello there,
I want to query historic process instances with date range. Actually my request is the following: I want all finished process instance in period of month before to current date.

I have tried something like that:

// get default process engine and history service from it...
ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();
HistoryService historyService = processEngine.getHistoryService();

List<HistoricProcessInstance> instanceList = historyService
        .createHistoricProcessInstanceQuery()
        .processDefinitionKey("process_key")
        .variableValueEquals("var1_key", "var1_value")
        .variableValueEquals("var2_key", "var2_value")
        .orderByProcessInstanceEndTime()
        .finished()
        .list();

How to include date range here?
Thank you in advance!

Hi @hedza06,

You can add #finishedBefore().

Best regards,
Yana

.startedAfter(beforeOneMonth)
.finishedBefore(currentDate)

can this two methods be combined?

I think so, is it working for you?

Yes, it works. Thank you :grinning: