# Get dates between start and end date

**URL:** <https://forum.inductiveautomation.com/t/get-dates-between-start-and-end-date/93514>\
**Category:** Ignition\
**Tags:** scripting\
**Created:** [July 22, 2024, 4:48am UTC](https://forum.inductiveautomation.com/t/get-dates-between-start-and-end-date/93514 "2024-07-22T04:48:31Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Vijay\_Krishna\_G\_M1](https://avatars.discourse-cdn.com/v4/letter/v/57b2e6/32.png) [@Vijay\_Krishna\_G\_M1](https://forum.inductiveautomation.com/u/Vijay_Krishna_G_M1)\
**Post date:** [July 22, 2024, 4:48am UTC](https://forum.inductiveautomation.com/t/get-dates-between-start-and-end-date/93514/1 "2024-07-22T04:48:31Z")

</div>

Dear Team, I am trying to get the dates between start and end date coming from view params, I am using value change script. Can someone guide me please

---

<div class="post-metadata">

**Author:** ![nminchin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nminchin/32/6911_2.png) [@nminchin](https://forum.inductiveautomation.com/u/nminchin)\
**Post date:** [July 22, 2024, 5:59am UTC](https://forum.inductiveautomation.com/t/get-dates-between-start-and-end-date/93514/2 "2024-07-22T05:59:20Z")

</div>

So, given 2024-07-01 and 2024-07-05, you would want:

```python
2024-07-02
2024-07-03
2024-07-04

```

?

---

<div class="post-metadata">

**Author:** ![Vijay\_Krishna\_G\_M1](https://avatars.discourse-cdn.com/v4/letter/v/57b2e6/32.png) [@Vijay\_Krishna\_G\_M1](https://forum.inductiveautomation.com/u/Vijay_Krishna_G_M1)\
**Post date:** [July 22, 2024, 6:06am UTC](https://forum.inductiveautomation.com/t/get-dates-between-start-and-end-date/93514/3 "2024-07-22T06:06:34Z")

</div>

Yes you are right @nminchin

---

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [July 22, 2024, 7:11am UTC](https://forum.inductiveautomation.com/t/get-dates-between-start-and-end-date/93514/4 "2024-07-22T07:11:03Z")

</div>

I'd probably do something like:

```python
days = [system.date.addDays(start_date, d) for d in xrange(system.date.daysBetween(start_date, end_date))]

```

But also, why ?

---

<div class="post-metadata">

**Author:** ![Vijay\_Krishna\_G\_M1](https://avatars.discourse-cdn.com/v4/letter/v/57b2e6/32.png) [@Vijay\_Krishna\_G\_M1](https://forum.inductiveautomation.com/u/Vijay_Krishna_G_M1)\
**Post date:** [July 22, 2024, 7:26am UTC](https://forum.inductiveautomation.com/t/get-dates-between-start-and-end-date/93514/5 "2024-07-22T07:26:56Z")

</div>

I haven't tried this, May I know does the output gives me the dates between two date

---

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [July 22, 2024, 7:51am UTC](https://forum.inductiveautomation.com/t/get-dates-between-start-and-end-date/93514/6 "2024-07-22T07:51:25Z")

</div>

I'll break this up for you:

- `system.date.daysBetween(start_date, end_date)`  
This will return the number of days between 2 dates
- xrange(n)  
This generates a list of numbers from 0 to n (including 0, excluding n)
- `[something(x) for x in iterable]`  
That's a list comprehension. It applies `something` to every `x` in an iterable, and makes a list from those
- `system.date.addDays(start_date, n)`  
This returns a date that's `n` days after the start date

To sum it up: This will generate a new date by adding x days to the start date, for every x up to the number of days between 2 dates.

So, yes, it will return the dates between two dates.

---

<div class="post-metadata">

**Author:** ![Vijay\_Krishna\_G\_M1](https://avatars.discourse-cdn.com/v4/letter/v/57b2e6/32.png) [@Vijay\_Krishna\_G\_M1](https://forum.inductiveautomation.com/u/Vijay_Krishna_G_M1)\
**Post date:** [July 22, 2024, 9:12am UTC](https://forum.inductiveautomation.com/t/get-dates-between-start-and-end-date/93514/7 "2024-07-22T09:12:12Z")

</div>

Thanks for the explanation @pascal.fragnoud
