# Python code return interval of date if date are between two month

**URL:** <https://forum.inductiveautomation.com/t/python-code-return-interval-of-date-if-date-are-between-two-month/52120>\
**Category:** Ignition\
**Created:** [October 19, 2021, 4:05pm UTC](https://forum.inductiveautomation.com/t/python-code-return-interval-of-date-if-date-are-between-two-month/52120 "2021-10-19T16:05:12Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![cesma2000](https://avatars.discourse-cdn.com/v4/letter/c/c6cbf5/32.png) [@cesma2000](https://forum.inductiveautomation.com/u/cesma2000)\
**Post date:** [October 19, 2021, 4:05pm UTC](https://forum.inductiveautomation.com/t/python-code-return-interval-of-date-if-date-are-between-two-month/52120/1 "2021-10-19T16:05:12Z")

</div>

Hi guys I need help.

I have a generic date (endDt of type Date) and, in python, I need to get all the dates that are from endDt going back of 7 days:  
Dy1=endDt-6  
Dy2=endDt-5  
Dy3=endDt-4  
Dy4=endDt-3  
Dy5=endDt-2  
Dy6=endDt-1  
Dy7=endDt

This must also work when the time window has days between two months and considering the differences of days between different months and leap years.

Thx to all that can tell me some input.

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [October 19, 2021, 4:57pm UTC](https://forum.inductiveautomation.com/t/python-code-return-interval-of-date-if-date-are-between-two-month/52120/2 "2021-10-19T16:57:38Z")

</div>

`system.date.addDays(endDt, -1)` will handle months, leap years, etc, appropriately.

[https://docs.inductiveautomation.com/pages/viewpage.action?pageId=58603988](https://docs.inductiveautomation.com/pages/viewpage.action?pageId=58603988)

---

<div class="post-metadata">

**Author:** ![cesma2000](https://avatars.discourse-cdn.com/v4/letter/c/c6cbf5/32.png) [@cesma2000](https://forum.inductiveautomation.com/u/cesma2000)\
**Post date:** [October 19, 2021, 6:42pm UTC](https://forum.inductiveautomation.com/t/python-code-return-interval-of-date-if-date-are-between-two-month/52120/3 "2021-10-19T18:42:53Z")

</div>

Thank you PG i’m new to ignition and i need to become more confident with your documentation.  
I’ll test it (tomorrow) and i’ll consider more this community to have some ‘inspiration’ in future.  
C.
