Trouble getting a custom date format | XM Community
Question

Trouble getting a custom date format

  • 23 April 2024
  • 3 replies
  • 34 views

Badge +1

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!


3 replies

Userlevel 1
Badge +6

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 = parts[0]; var timePart = parts[1].split(":"); var formattedDate = datePart.replace(/-/g, "/") + " " + timePart[0] + ":" + timePart[1] + ":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.

Badge +1

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 = parts[0]; var timePart = parts[1].split(":"); var formattedDate = datePart.replace(/-/g, "/") + " " + timePart[0] + ":" + timePart[1] + ":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!

Userlevel 4
Badge +8

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