Format Query String Data to Date/Time | XM Community
Skip to main content
Solved

Format Query String Data to Date/Time

  • November 20, 2025
  • 5 replies
  • 42 views

Forum|alt.badge.img+1

I have a survey where we need to use an anonymous link, but we are embedding certain details into the query string to give us certain details.  The link is something like www.survey.com/?D=YYYYMMDD&T=HHMM, so the actual link would be something like www.survey.com/?D=20251120&T=1015

I want to use that data as date/time segmentation on the dashboards.  I will set those up using this process (https://www.qualtrics.com/support/vocalize/dashboard-settings-cx/dashboard-data/date-time-segmentation-cx/).

I’m capturing both D & T as embedded data with a value that is being set by the URL.  I added a separate embedded data field called FormattedDate and another called FormattedTime so I can save them as YYYY-MM-DD and HH:MM, then I added a third embedded data value as DateTimeCombined, and just added the FormattedDate & FormattedTime together, separated by a space.

That would give me the data in a YYYY-MM-DD HH:MM format.  However, I can’t figure out how to do the formatting on the FormattedDate & FormattedTime embedded data to split add the dashes (-) or the colon (:).

Any ideas on how I can accomplish this?

Best answer by vgayraud

@TomG is right then, you’ll need to add javascript to the 1st question (assuming all respondents see it).

I’d be tempted to treat it as a string to avoid timezone problems (and assuming your hour has always 4 digits). Something like that:

Qualtrics.SurveyEngine.addOnReady(function () {

Qualtrics.SurveyEngine.setEmbeddedData('DateTimeCombined', '${e://Field/D}'.slice(0, 4) + '-' + '${e://Field/D}'.slice(4, 6) + '-' + '${e://Field/D}'.slice(6, 8) + 'T' + '${e://Field/T}'.slice(0, 2) + ':' + '${e://Field/T}'.slice(2, 4));

});

 

5 replies

TomG
Level 8 ●●●●●●●●
Forum|alt.badge.img+27
  • Level 8 ●●●●●●●●
  • November 20, 2025

@MB_XPM,

Qualtrics doesn’t have a string functions (e.g., substr) that you can use when setting embedded data from the survey flow. So, you would have to use JavaScript to parse the date and time strings and save them to the third embedded data field.


vgayraud
QPN Level 6 ●●●●●●
Forum|alt.badge.img+58
  • QPN Level 6 ●●●●●●
  • November 21, 2025

Hi,

Wouldn’t using a custom format date on your DateTimeCombined field in the dashboard be enough for your needs?

 


Forum|alt.badge.img+1
  • Author
  • November 21, 2025

@vgayraud thanks for the response, this does work to format the date into something I can use for date filters.  However, I am also using this DateTimeCombined field for date time segmentation, which requires the date field to be formatted to ISO 8601 format, and that has to be done beforehand.

 


vgayraud
QPN Level 6 ●●●●●●
Forum|alt.badge.img+58
  • QPN Level 6 ●●●●●●
  • Answer
  • November 22, 2025

@TomG is right then, you’ll need to add javascript to the 1st question (assuming all respondents see it).

I’d be tempted to treat it as a string to avoid timezone problems (and assuming your hour has always 4 digits). Something like that:

Qualtrics.SurveyEngine.addOnReady(function () {

Qualtrics.SurveyEngine.setEmbeddedData('DateTimeCombined', '${e://Field/D}'.slice(0, 4) + '-' + '${e://Field/D}'.slice(4, 6) + '-' + '${e://Field/D}'.slice(6, 8) + 'T' + '${e://Field/T}'.slice(0, 2) + ':' + '${e://Field/T}'.slice(2, 4));

});

 


Forum|alt.badge.img+1
  • Author
  • November 24, 2025

@vgayraud Thank you, this was the route that I ended up needing to go down.  I had to make some slight changes but essentially used what you provided above.  One note in case others come across this down the road, the embedded data field needed to be setup as “__js_DateTimeCombined” as the javascript was adding that to the embedded data.