Change Format of Embedded Data Date | Experience Community
Skip to main content

Change Format of Embedded Data Date

  • March 11, 2022
  • 2 replies
  • 709 views

Forum|alt.badge.img+10

I am sending a date from one survey through a query string to an embedded data field in a second one. In my survey flow, I have set the embedded data Variable Type to Date in order to use filter associated with date formatted fields.
When I use the embedded date field in the second survey in a report, however, Qualtrics displays the value as datetime (2022-03-11T00:00:00.000Z). What I am trying display is simply 2022-03-11. Can anyone recommend the best way to accomplish this?

2 replies

KWigg
Level 2 ●●
Forum|alt.badge.img+9
  • Level 2 ●●
  • September 11, 2023

I’m disappointed there’s no response to this in a year! I, too, need to take a field that is ingested as datetime, and record it in a separate field as just date since Dashboard filters can’t use datetime fields.


arunxmarchitect
Level 4 ●●●●
Forum|alt.badge.img+8

@brianj ​@KWigg , 

Qualtrics does not currently provide a built-in function within the Survey Flow to reformat an Embedded Data field value (for example, converting 2022-03-11T00:00:00.000Z to 2022-03-11) without using JavaScript or a post-survey workflow.

One approach is to add JavaScript to the first survey. When the date field is passed through the query string to the second survey, the JavaScript can format the date before storing or sending the value.

This ensures the receiving survey gets the date in the required YYYY-MM-DD format, which can then be used correctly for date-based filters and reporting.

Qualtrics.SurveyEngine.addOnload(function () {

// Replace "EmbeddedDate" with your Embedded Data field name
var dateValue = "${e://Field/EmbeddedDate}";

if (dateValue) {
// Keep only the YYYY-MM-DD portion
var formattedDate = dateValue.split("T")[0];

// Save it back to Embedded Data
Qualtrics.SurveyEngine.setEmbeddedData("EmbeddedDate", formattedDate);
}

});