# Window for the last N minutes

**URL:** <https://forum.confluent.io/t/window-for-the-last-n-minutes/2551>\
**Category:** Kafka Streams\
**Created:** [22 August 2021 07:29 UTC](https://forum.confluent.io/t/window-for-the-last-n-minutes/2551 "2021-08-22T07:29:40Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sason](https://avatars.discourse-cdn.com/v4/letter/s/f6c823/32.png) [@Sason](https://forum.confluent.io/u/Sason)\
**Post date:** [22 August 2021 07:29 UTC](https://forum.confluent.io/t/window-for-the-last-n-minutes/2551/1 "2021-08-22T07:29:40Z")

</div>

Hi all,  
We want to achieve ​a view of the last N minutes per key.  
We want a single window that slides over the time axis, for example:

A window is defined with a time difference of 5 minutes - all events that are less then 5 minutes apart should be in the window.  
Event A: 10:00 [A]  
Event B: 10:03 [A, B]  
Event C: 10:06 [B, C]

We tried using hopping/sliding windows, but they’re both opening multiple windows. Is it possible to have 1 window that updates over time?

---

<div class="post-metadata">

**Author:** ![mjsax](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.confluent.io/mjsax/32/3113_2.png) [@mjsax](https://forum.confluent.io/u/mjsax)\
**Post date:** [25 August 2021 23:25 UTC](https://forum.confluent.io/t/window-for-the-last-n-minutes/2551/2 "2021-08-25T23:25:28Z")

</div>

Did you try to use `windowBy(SlidingWindows.withTimeDifference(...))` ?
