Parse Date Range Picker repsonse

Hi Pratik,

Could you please help with below query:

I need to access dates from object variable of date range picker. However, we need both the dates i.e. first selected and the last one. How to code this.
Please reply.

1 Like

Hey @Rahul_Zirpe

You can refer to this doc to understand more about the date range picker response. It’ll be stored in the object variable, and the sample response is given in the doc: Prompts and Messages | yellow.ai

Hi Pratik,

Thanks for the update.

I have already read this document but I haven’t got anything about date range picker widget. Could you please help me with this as I need to submit my project to yellow.ai today.

1 Like

Definately @Rahul_Zirpe

As shown in the guide, for Date Range you can refer to this sample response:

{
    "value": {
                "timestamp": "2021-09-08T00:00:00.000Z",
                "year": 2021,
                "month": 8,
                "date": 8,
                "day": "Sunday",
                "hour": 0,
                "minute": 0
            },
    "range": {
        "exists": true,
        start:
            {
                "timestamp": "2021-09-08T00:00:00.000Z",
                "year": 2021,
                "month": 8,
                "date": 8,
                "day": "Sunday",
                "hour": 0,
                "minute": 0
            },
        end:
            {
                "timestamp": "2021-09-08T00:00:00.000Z",
                "year": 2021,
                "month": 8,
                "date": 9,
                "day": "Monday",
                "hour": 0,
                "minute": 0
            }
    }
}

You can use following code snippet to access values from the response:

  • Start Date: {{{variables.variable_name.range.start.date}}}
  • End Date: {{{variables.variable_name.range.end.date}}}

Please feel free to comment down below if you face any issue.

1 Like

Thank you Pratik. It works.:+1:
Just need to understand how to check the inside structure of objects variable. As you already informed to get access of code. I tried but still it is not working.

1 Like

You can refer to this guide for more information about the code functions: Code | yellow.ai

First you need to store the response of a prompt in a variable and you can log in using this syntax: console.log(data.variables.variable_name);