# List of Months between to Dates

**URL:** <https://community.glideapps.com/t/list-of-months-between-to-dates/59007>\
**Category:** Ask for Help\
**Created:** [March 10, 2023, 8:11pm UTC](https://community.glideapps.com/t/list-of-months-between-to-dates/59007 "2023-03-10T20:11:54Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![constantinos\_christo](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/constantinos_christo/32/55508_2.png) [@constantinos\_christo](https://community.glideapps.com/u/constantinos_christo)\
**Post date:** [March 10, 2023, 8:11pm UTC](https://community.glideapps.com/t/list-of-months-between-to-dates/59007/1 "2023-03-10T20:11:54Z")

</div>

Hey everyone,

I have been struggling with the following and I would really appreciate your help.

The user inputs a start date and an end date I want to get a list of the months so I use them as choices in a drop down list.

Example:  
Start Date: 1st of September  
End Date: 15th of December  
Output: September, October, November, December (as text)

The dates can vary so it has to be dynamic and the output needs to be in a way that can be then used in the form.

Thanks a lot in advance!

---

<div class="post-metadata">

**Author:** ![ThinhDinh](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/thinhdinh/32/49_2.png) [@ThinhDinh](https://community.glideapps.com/u/ThinhDinh)\
**Post date:** [March 11, 2023, 1:29am UTC](https://community.glideapps.com/t/list-of-months-between-to-dates/59007/2 "2023-03-11T01:29:40Z")

</div>

> [@constantinos\_christo](#):
>
> The user inputs a start date and an end date I want to get a list of the months so I use them as choices in a drop down list.

Is this happening in a form or a details screen?

---

<div class="post-metadata">

**Author:** ![constantinos\_christo](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/constantinos_christo/32/55508_2.png) [@constantinos\_christo](https://community.glideapps.com/u/constantinos_christo)\
**Post date:** [March 11, 2023, 3:10am UTC](https://community.glideapps.com/t/list-of-months-between-to-dates/59007/3 "2023-03-11T03:10:20Z")

</div>

The start and end dates are submitted initially through a form. Then I want to extract the list of months and have them available to be used as choices in another form.

---

<div class="post-metadata">

**Author:** ![Uzo](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/uzo/32/22639_2.png) [@Uzo](https://community.glideapps.com/u/Uzo)\
**Post date:** [March 11, 2023, 4:48am UTC](https://community.glideapps.com/t/list-of-months-between-to-dates/59007/4 "2023-03-11T04:48:15Z")

</div>

![Screen Shot 2023-03-10 at 11.45.52 PM](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/5/2/52af9dbef2ccefc673db5a27f7129eb09550ee5b.jpeg)

Use the Java column and paste this code:

```auto
var start= new Date(p1);
var start1= new Date(start.setDate(1));
var end = new Date(p2);
var res='';
var difference = (end.getFullYear()*12 + end.getMonth()) - (start.getFullYear()*12 + start.getMonth())+1;
for(var i=0; i<difference; ++i){
var newDate = new Date(start.setMonth(start1.getMonth()+i));
var month = newDate.toLocaleString('default', { month: 'long' });
res=res+month+', ';
}
return res

```

Then use the split column to create an array… then turn that array into a list.

Or, if you don’t need months in one string… then you can use this code to create a list… but first copy the start and end date to all rows using a single value column… add a row number column starting from 0:

 ![Screen Shot 2023-03-11 at 12.24.45 AM](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/8/4/84fc3414ba27d627d7c3b3f7c9c537b8cd442a06.jpeg)

```auto
var start= new Date(p1);
var start1= new Date(start.setDate(1));
var end = new Date(p2);
var res='';
var difference = (end.getFullYear()*12 + end.getMonth()) - (start.getFullYear()*12 + start.getMonth())+1;
if(difference>p3){
var newDate = new Date(start.setMonth(start1.getMonth()+p3));
var month = newDate.toLocaleString('default', { month: 'long' });
res=month;
}
return res

```

---

<div class="post-metadata">

**Author:** ![constantinos\_christo](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/constantinos_christo/32/55508_2.png) [@constantinos\_christo](https://community.glideapps.com/u/constantinos_christo)\
**Post date:** [March 11, 2023, 1:14pm UTC](https://community.glideapps.com/t/list-of-months-between-to-dates/59007/5 "2023-03-11T13:14:01Z")

</div>

This is exactly what I was looking for. Thank you Sir!

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/system/32/53398_2.png) [@system](https://community.glideapps.com/u/system)\
**Post date:** [March 12, 2023, 1:14pm UTC](https://community.glideapps.com/t/list-of-months-between-to-dates/59007/6 "2023-03-12T13:14:15Z")

</div>

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.
