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

change format of birthdate embedded data from directory


Forum|alt.badge.img+1

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?   

Best answer by Shashi

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);

 

View original

2 replies

Shashi
Level 8 ●●●●●●●●
Forum|alt.badge.img+32
  • Level 8 ●●●●●●●●
  • 633 replies
  • Answer
  • June 11, 2024

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);

 


Forum|alt.badge.img+1
  • Author
  • Level 1 ●
  • 4 replies
  • June 13, 2024

Perfect!! Thank you so much!


Leave a Reply