57
Views
4
Comments
Generate a list of months between two dates
Question

I have created a page which generates an Excel template. The user Enters a start month and end month (using month picker). Now on clicking the download template button, an Excel template needs to be created with the months being used as headers. 

If the user selects August 2023 to May 2024 Final file should look like this:

The main issue I'm facing is getting the list of months. Any help would be appreciated. Thanks

2023-01-11 14-38-58
TESI-Sherwin

Hi @N Das 

I was able to replicate the final file using

1. Advanced Excel - to download with Excel format, to merge and insert values per cell.

https://www.outsystems.com/forge/component-overview/355/advanced-excel-o11

2. Sort the record list - to distinct years per month (can remove if you can distinct the year on the list)

https://www.outsystems.com/forge/component-overview/22/sortrecordlist-o11

3. some logic


I also attached some comments here and instruction

If you have any questions just let me know.

2019-01-07 16-04-16
Siya
 
MVP

You need to create an action that will return the list of months for the given two input dates (start date, end date). Within this action, implement an adhoc loop beginning from the start date and proceeding until the end date, advancing one month with each iteration. During each loop cycle, extract the name of the current month by applying the FormatDateTime function on the loop's current date with the format "MMMM", and add this month name to your accumulating month list. After completing the loop, output the compiled list of month names.

UserImage.jpg
Ravichand GY

Hello , 

I'm attaching my OML for your reference check it out

Regards,

Ravichand GY

Dates.oml
2020-09-15 13-07-23
Kilian Hekhuis
 
MVP

Hi N,

Siya wrote a good description of how to create a list of months. Note that to put that in an Excel as column names, you cannot use the out-of-the-box Excel functionality that the Platform offers (as it needs fixed column definitions), but you can use the Advanced Excel Forge asset.

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.