Community Groups are officially here!
We've released Groups, a new feature that enables us to connect community members of similar industries and interests in a shared, private space. You can check out all of the details here, including information about who can join, how to join, and what Groups are currently offered. Please leave your feedback through this Community Groups Feedback Survey.

How to get date range from flatpickr?

bjorgenson
bjorgenson Omaha, NECommunity Member, Qualtrics Brand Admin Qubie ✭

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.

Best Answer

  • TomG
    TomG Raleigh, NCCommunity Member, Qualtrics Brand Admin Wizard ✭✭✭✭✭
    edited May 2018 Accepted Answer

    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.