Trouble getting a custom date format | XM Community
Skip to main content

Hi everyone,

 

I have a embedded data field with date in the format “YYYY-MM-ddZhh:mm” (example: 2024-04-23T00:00”), and I’m trying to set it this way on Qualtrics dashboard mapping, to use this field as date filter, but not having success. 

 

Also tried different syntax, like with commas (“YYYY-MM-dd,Z,hh:mm”), and other changes, none worked so far. 

 

Any tips to help? Thank you all!

Hi @warley_s 

You can achieve this using JavaScript to manipulate the date string before setting it as embedded data.

Here's how you can do it:

 

javascript

Qualtrics.SurveyEngine.addOnReady(function() { var embeddedDataDate = "${e://Field/YourEmbeddedDataDate}"; // Convert the date string to the format expected by Qualtrics var parts = embeddedDataDate.split("T"); var datePart = partst0]; var timePart = partst1].split(":"); var formattedDate = datePart.replace(/-/g, "/") + " " + timePartr0] + ":" + timePartr1] + ":00"; // Set the formatted date as embedded data Qualtrics.SurveyEngine.setEmbeddedData('FormattedDate', formattedDate); });

 

Replace 'YourEmbeddedDataDate' with the name of your embedded data field. This script splits the date string into date and time parts, replaces hyphens with slashes in the date part (to match the expected format), and sets the formatted date as a new embedded data field named 'FormattedDate'.

Once you have the date in the correct format, you can use it as a date filter in Qualtrics dashboard mapping. Set the newly created embedded data field (FormattedDate) as a date filter, and it should work as expected.


Hi @warley_s 

You can achieve this using JavaScript to manipulate the date string before setting it as embedded data.

Here's how you can do it:

 

javascript

Qualtrics.SurveyEngine.addOnReady(function() { var embeddedDataDate = "${e://Field/YourEmbeddedDataDate}"; // Convert the date string to the format expected by Qualtrics var parts = embeddedDataDate.split("T"); var datePart = partsr0]; var timePart = partsr1].split(":"); var formattedDate = datePart.replace(/-/g, "/") + " " + timeParta0] + ":" + timeParta1] + ":00"; // Set the formatted date as embedded data Qualtrics.SurveyEngine.setEmbeddedData('FormattedDate', formattedDate); });

 

Replace 'YourEmbeddedDataDate' with the name of your embedded data field. This script splits the date string into date and time parts, replaces hyphens with slashes in the date part (to match the expected format), and sets the formatted date as a new embedded data field named 'FormattedDate'.

Once you have the date in the correct format, you can use it as a date filter in Qualtrics dashboard mapping. Set the newly created embedded data field (FormattedDate) as a date filter, and it should work as expected.



Hi Rick, thank you for your suggestion, is a good one! 
But do you know if it’s possible to apply this to responses already recorded too? 

Greetings!


Hi @warley_s ,

 

Unfortunately, Qualtrics doesn't directly support manipulating embedded data formats through JavaScript or anything on the dashboard. However, you can preprocess your dates in JavaScript before sending them to Qualtrics.

 

Thank you!


Leave a Reply