change format of birthdate embedded data from directory | XM Community
Skip to main content

I have a survey that requires participants to authenticate using an ID. After authenticating, I have a Text/Graphic question that uses piped text to populate Name, Location, and Birthdate that is embedded data from a CX Contacts Directory.

The birthdate format in the directory is YYYY/MM/DD. Is there a way to change the format in the Text/Graphic question so it displays to the participant as MM/DD/YYYY?   

In the HTML view of text/graphic question, wrap the s_Birthdate piping in a span tag with id date as seen below:

<span id="date">${e://Field/s_Birthdate}</span>

Add below JS in the JS option of the same question:

var dateStr = "${e://Field/s_Birthdate}";
var parts = dateStr.split('/');
var formattedDate = parts[1] + '/' + parts[2] + '/' + parts[0];
jQuery('#date').text(formattedDate);

 


Perfect!! Thank you so much!


Leave a Reply