How to get date range from flatpickr? | XM Community
Skip to main content
So I have flatpickr working in qualtrics with this code:

!

And it returns a value of something like this: 2018-05-30 to 2018-05-31



I want to take the returned value split it at the " to " and then convert each of those values to epoch time so I can subtract them and find the number of days in the range. So far I have this:

!



But I can't seem to get the slipt to work, most of the code was borrowed from another post, sorry my JS is not great.
It isn't clear to me if the second script is on a different page than the first script. It would have to be the way you've written the script. The problem is you haven't used getEmbeddedData correctly. In fact, you don't need it at all. Just pipe the answer to you question into the script, but is has to be inside quotes:

```

var Coverage_Beg_DT = "${q://QID291/ChoiceTextEntryValue}";

```

As for your calculation, you should consider using moment.js which will help you calculate the difference between two dates.

Leave a Reply