change format of birthdate embedded data from directory | XM Community
Solved

change format of birthdate embedded data from directory

  • 10 June 2024
  • 2 replies
  • 19 views

Badge +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?   

icon

Best answer by Shashi 11 June 2024, 11:42

View original

2 replies

Userlevel 6
Badge +27

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

 

Badge +1

Perfect!! Thank you so much!

Leave a Reply