Repeater module problem





I’m trying to get the dates between two given dates, which will be used separately for operations. The number of dates between date A and B is outputted correctly. However, the repeater module does not output date A. If I enter the initial value as 0, it does not output date B. But I need the output to be A and B and all the dates in between. How can I achieve this?

In the example above, date A was 30 of July and date B was 2nd of August.

Welcome to the Make community!

Your initial value probably needs to start from 0 if you want to start from the current/start date.

Then, to end with the final date inclusive, you need to add a 1 to the calculated days.

Example

Screenshot_2024-07-29_220755

Output

Hope this helps! Let me know if there are any further issues!

samliewrequest private consultation

Join the Make Fans Discord server to chat with other makers!

2 Likes

Module Export

You can copy and paste this module export into your scenario. This will paste the modules shown in my screenshots above.

  1. Copy the JSON code below by clicking the copy button when you mouseover the top-right of the code block
    Screenshot_2024-01-17_200117

  2. Enter your scenario editor. Press ESC to close any dialogs. Press CTRLV (paste keyboard shortcut for Windows) to paste directly in the canvas.

  3. Click on each imported module and save it for validation. You may be prompted to remap some variables and connections.

Click to Expand Module Export Code

JSON - Copy and Paste this directly in the scenario editor

{
    "subflows": [
        {
            "flow": [
                {
                    "id": 1,
                    "module": "util:SetVariables",
                    "version": 1,
                    "parameters": {},
                    "mapper": {
                        "variables": [
                            {
                                "name": "start_date",
                                "value": "{{parseDate(\"30/07/2024\"; \"DD/MM/YYYY\")}}"
                            },
                            {
                                "name": "end_date",
                                "value": "{{parseDate(\"02/08/2024\"; \"DD/MM/YYYY\")}}"
                            }
                        ],
                        "scope": "roundtrip"
                    },
                    "metadata": {
                        "designer": {
                            "x": 0,
                            "y": 0,
                            "name": "Start/End Dates"
                        },
                        "restore": {
                            "expect": {
                                "variables": {
                                    "items": [
                                        null,
                                        null
                                    ]
                                },
                                "scope": {
                                    "label": "One cycle"
                                }
                            }
                        },
                        "expect": [
                            {
                                "name": "variables",
                                "type": "array",
                                "label": "Variables",
                                "spec": [
                                    {
                                        "name": "name",
                                        "label": "Variable name",
                                        "type": "text",
                                        "required": true
                                    },
                                    {
                                        "name": "value",
                                        "label": "Variable value",
                                        "type": "any"
                                    }
                                ]
                            },
                            {
                                "name": "scope",
                                "type": "select",
                                "label": "Variable lifetime",
                                "required": true,
                                "validate": {
                                    "enum": [
                                        "roundtrip",
                                        "execution"
                                    ]
                                }
                            }
                        ],
                        "interface": [
                            {
                                "name": "start_date",
                                "label": "start_date",
                                "type": "any"
                            },
                            {
                                "name": "end_date",
                                "label": "end_date",
                                "type": "any"
                            }
                        ]
                    }
                },
                {
                    "id": 2,
                    "module": "builtin:BasicRepeater",
                    "version": 1,
                    "parameters": {},
                    "mapper": {
                        "start": "0",
                        "repeats": "{{ceil((1.end_date - 1.start_date) / 86400000) + 1}}",
                        "step": "1"
                    },
                    "metadata": {
                        "designer": {
                            "x": 248,
                            "y": 0,
                            "name": "Iterate number of days"
                        },
                        "restore": {},
                        "expect": [
                            {
                                "name": "start",
                                "type": "number",
                                "label": "Initial value",
                                "required": true
                            },
                            {
                                "name": "repeats",
                                "type": "number",
                                "label": "Repeats",
                                "validate": {
                                    "min": 0,
                                    "max": 10000
                                },
                                "required": true
                            },
                            {
                                "name": "step",
                                "type": "number",
                                "label": "Step",
                                "required": true
                            }
                        ]
                    }
                },
                {
                    "id": 3,
                    "module": "util:TextAggregator",
                    "version": 1,
                    "parameters": {
                        "rowSeparator": "\n",
                        "feeder": 2
                    },
                    "mapper": {
                        "value": "{{formatDate(addDays(1.start_date; 2.i); \"DD/MM/YYYY\")}}"
                    },
                    "metadata": {
                        "designer": {
                            "x": 495,
                            "y": 1,
                            "name": "Aggregator",
                            "messages": [
                                {
                                    "category": "last",
                                    "severity": "warning",
                                    "message": "A transformer should not be the last module in the route."
                                }
                            ]
                        },
                        "restore": {
                            "parameters": {
                                "rowSeparator": {
                                    "label": "New row"
                                }
                            },
                            "extra": {
                                "feeder": {
                                    "label": "Repeater [2]"
                                }
                            },
                            "flags": {
                                "groupBy": {
                                    "collapsed": true
                                },
                                "stopIfEmpty": {
                                    "collapsed": true
                                }
                            }
                        },
                        "parameters": [
                            {
                                "name": "rowSeparator",
                                "type": "select",
                                "label": "Row separator",
                                "validate": {
                                    "enum": [
                                        "\n",
                                        "\t",
                                        "other"
                                    ]
                                }
                            }
                        ],
                        "expect": [
                            {
                                "name": "value",
                                "type": "text",
                                "label": "Text"
                            }
                        ],
                        "advanced": true
                    }
                }
            ]
        }
    ],
    "metadata": {
        "version": 1
    }
}

Hope this helps! Let me know if there are any further issues!

samliewrequest private consultation

Join the Make Fans Discord server to chat with other makers!

Thank you @samliew !

2 Likes