# How to get all the running process instances

**URL:** <https://forum.flowable.org/t/how-to-get-all-the-running-process-instances/9601>\
**Category:** Flowable Engine\
**Created:** [August 2, 2022, 2:49pm UTC](https://forum.flowable.org/t/how-to-get-all-the-running-process-instances/9601 "2022-08-02T14:49:37Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![flowableUser42](https://avatars.discourse-cdn.com/v4/letter/f/7bcc69/32.png) [@flowableUser42](https://forum.flowable.org/u/flowableUser42)\
**Post date:** [August 2, 2022, 2:49pm UTC](https://forum.flowable.org/t/how-to-get-all-the-running-process-instances/9601/1 "2022-08-02T14:49:37Z")

</div>

Hi, I am new to Flowable and I need to query all the running process instances that were started over a X period of time. For example, I want to query the process instances that are “older” than 15 days. How can I achieve this?

Thank you

---

<div class="post-metadata">

**Author:** ![arthware](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.flowable.org/arthware/32/2869_2.png) [@arthware](https://forum.flowable.org/u/arthware)\
**Post date:** [August 2, 2022, 4:10pm UTC](https://forum.flowable.org/t/how-to-get-all-the-running-process-instances/9601/2 "2022-08-02T16:10:48Z")

</div>

Just have a look at the documentation until the “Query” chapter:

> **[The Flowable API · Flowable Open Source Documentation](https://www.flowable.com/open-source/docs/bpmn/ch04-API)**
>
> \## The Process Engine API and services

Something like:

```auto
ProcessEngine processEngine = // get engine instance
List<ProcessInstance> result = processEngine.getRuntimeService()
.createProcessInstanceQuery()
.startedBefore(/*date*/)
.list()

```

---

<div class="post-metadata">

**Author:** ![flowableUser42](https://avatars.discourse-cdn.com/v4/letter/f/7bcc69/32.png) [@flowableUser42](https://forum.flowable.org/u/flowableUser42)\
**Post date:** [August 2, 2022, 8:59pm UTC](https://forum.flowable.org/t/how-to-get-all-the-running-process-instances/9601/3 "2022-08-02T20:59:59Z")

</div>

Hi Arthur! Thank you for replying. This is what I needed it. One more question,

If I also want to query the list of running processes that started before a given date AND also  
contain an execution variable named “isValidUntilDate” of type Date whose value is a date has passed. Do I need to create a native query for this intend? or is there a way to achieve this using the Query API similarly?

Thank you in advance!

---

<div class="post-metadata">

**Author:** ![arthware](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.flowable.org/arthware/32/2869_2.png) [@arthware](https://forum.flowable.org/u/arthware)\
**Post date:** [August 3, 2022, 6:48am UTC](https://forum.flowable.org/t/how-to-get-all-the-running-process-instances/9601/4 "2022-08-03T06:48:25Z")

</div>

This should be possible with the “variableValue\*\*” or “scopedVariableValue\*\*” query methods.

```auto
List<ProcessInstance> result = processEngine.getRuntimeService()
.createProcessInstanceQuery()
.startedBefore(/*date*/)
.variableValueGreaterThanOrEqual("isValidUntilDate", new Date())
.list()

```

Best, Arthur
