# Range function to display months

**URL:** <https://community.hubspot.com/t/range-function-to-display-months/141652>\
**Category:** CMS Development\
**Created:** [October 27, 2025, 5:07pm UTC](https://community.hubspot.com/t/range-function-to-display-months/141652 "2025-10-27T17:07:06Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![ben-duchy](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/ben-duchy/32/84083_2.png) [@ben-duchy](https://community.hubspot.com/u/ben-duchy)\
**Post date:** [October 27, 2025, 5:07pm UTC](https://community.hubspot.com/t/range-function-to-display-months/141652/1 "2025-10-27T17:07:06Z")

</div>

I really hope someone can help me with this, I’ve been stuck for ages, even ChatGPT hasn’t been able to fix it.  
I’ve set a date within my module called “business\_start\_date” and set it to the 1st July. I would now like to to loop through all 12 months using a range function, however it is missing out October and repeating March! I’m really puzzled why it’s doing this.

```lia-code-sample
{% for month_no in range(1, 13) %}
{% set month_start = module.business_start_date | plus_time(month_no, "months") %} 
{{ month_start | format_date('MMMM YYYY') }}<br>
{% endfor %}

```

---

<div class="post-metadata">

**Author:** ![BarryGrennan](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/barrygrennan/32/97794_2.png) [@BarryGrennan](https://community.hubspot.com/u/BarryGrennan)\
**Post date:** [October 27, 2025, 5:32pm UTC](https://community.hubspot.com/t/range-function-to-display-months/141652/2 "2025-10-27T17:32:02Z")

</div>

ChatGPT can be rubbish for hubl tbh, a lot of the time it treats it as if it’s exactly the same as jinja.  
But… your code seems to work for me. Here’s what it outputs:  
August 2025  
September 2025  
October 2025  
November 2025  
December 2025  
January 2026  
February 2026  
March 2026  
April 2026  
May 2026  
June 2026  
July 2026  
Could your date format have something to do with it?  
1st of July 2025 for my account is 01/07/2025  
Just weird that it would work on my end but not yours, so maybe something to do with date formatting?  
What are you seeing if you pprint your month\_start in the loop?

* * *

**Barry Grennan**

[Freelance HubSpot CMS Developer](https://www.seoanseo.ca?utm_source=HubSpotCommunity)

[Website](https://www.seoanseo.ca?utm_source=HubSpotCommunity) | [Contact](https://www.seoanseo.ca/contact?utm_source=HubSpotCommunity) | [LinkedIn](https://www.linkedin.com/in/barrygrennan)

---

<div class="post-metadata">

**Author:** ![kosalaindrasiri](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/kosalaindrasiri/32/44349_2.png) [@kosalaindrasiri](https://community.hubspot.com/u/kosalaindrasiri)\
**Post date:** [October 27, 2025, 8:06pm UTC](https://community.hubspot.com/t/range-function-to-display-months/141652/3 "2025-10-27T20:06:57Z")

</div>

Hey @ben-duchy,

Your code worked as expected on my end.

Here is a screenshot of the output.

 ![159803iD23090B4C9F4A8CB.png](https://d2qpr2jzcazej7.cloudfront.net/original/3X/2/b/2b36165de88984b193b3b5f45b94ab2ff7c37a74.png)

If you are looking to loop from the chosen date, This code snippet worked for me,

```lia-code-sample
{% set current_month = module.business_start_date %}
{% for month_no in range(0, 12) %}
 {{ current_month | format_date('MMMM YYYY') }}<br>
 {% set current_month = current_month | plus_time(1, "months") %}
{% endfor %}

```

Hope this will helps!

Best Regards,

---

<div class="post-metadata">

**Author:** ![ben-duchy](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/ben-duchy/32/84083_2.png) [@ben-duchy](https://community.hubspot.com/u/ben-duchy)\
**Post date:** [October 28, 2025, 9:38am UTC](https://community.hubspot.com/t/range-function-to-display-months/141652/4 "2025-10-28T09:38:26Z")

</div>

Thanks @BarryGrennan & @kosalaindrasiri for testing this. It’s strange how you’re both getting the correct view and I’m not.  
I’ve updated the code to yours @kosalaindrasiri but it’s still doing it, see screenshot. The 1st is the output from my original.  
However, I have just dicsovered that if I change the date to the 2nd July, it displays all the months in the correct order with no duplications. Any idea why this fixes it?

 ![159844i93507A1BC41DEC41.png](https://d2qpr2jzcazej7.cloudfront.net/original/3X/8/6/86ad57b63161a423341fad6bda0a14fd8d54af35.png)

---

<div class="post-metadata">

**Author:** ![ben-duchy](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/ben-duchy/32/84083_2.png) [@ben-duchy](https://community.hubspot.com/u/ben-duchy)\
**Post date:** [October 28, 2025, 9:53am UTC](https://community.hubspot.com/t/range-function-to-display-months/141652/5 "2025-10-28T09:53:22Z")

</div>

A further discovery, if I add a timezone on either mine or @kosalaindrasiri example, it fixes it!

`{{ current_month | format_date('MMMM YYYY', 'America/New_York') }}`

---

<div class="post-metadata">

**Author:** ![BarryGrennan](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/barrygrennan/32/97794_2.png) [@BarryGrennan](https://community.hubspot.com/u/BarryGrennan)\
**Post date:** [October 28, 2025, 10:27am UTC](https://community.hubspot.com/t/range-function-to-display-months/141652/6 "2025-10-28T10:27:29Z")

</div>

Ok, I guess it’s to do with the timezone of your portal then.

* * *

**Barry Grennan**

[Freelance HubSpot CMS Developer](https://www.seoanseo.ca?utm_source=HubSpotCommunity)

[Website](https://www.seoanseo.ca?utm_source=HubSpotCommunity) | [Contact](https://www.seoanseo.ca/contact?utm_source=HubSpotCommunity) | [LinkedIn](https://www.linkedin.com/in/barrygrennan)

---

<div class="post-metadata">

**Author:** ![ben-duchy](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/ben-duchy/32/84083_2.png) [@ben-duchy](https://community.hubspot.com/u/ben-duchy)\
**Post date:** [October 29, 2025, 9:38am UTC](https://community.hubspot.com/t/range-function-to-display-months/141652/7 "2025-10-29T09:38:56Z")

</div>

You’re probably right, although under settings my account is set to UK date format and the timezone is UTC +00:00 London, unless there’s something I’ve missed?
