I have an ED field with a date, how do I make a new ED field with just the year from that date? | XM Community
Skip to main content
Basically I have an ED field for date that is in this format MM/DD/YYYY. I would like to create a new ED field that just contains the YYYY portion of the first ED field so I can do a results report breakout by Year. Can this be done in Qualtrics or do I need to export to Excel then import?
hey @uhrxx005 ,



since you are having date stored in embedded variable.

You can use split function in javascript to get yyyy part.

Please check this link



Hope it helps
refer below post too



https://www.qualtrics.com/community/discussion/475/how-to-split-a-string-using-2-different-separators



`var dob_entry = getTextValue();

var split_dob = dob_entry.split("/");

var month = split_dob[0];

var day = split_dob[1];

var year = split_dob[2];`
You will first have to create an embedded data "CurrentYear" in survey flow and then add below code in JavaScript part "onReady" section



var CurrentYear1 = "${date://CurrentDate/SL}";

CurrentYear1 = CurrentYear1.split("/");

var CurrentYear2 = CurrentYear1[2];

Qualtrics.SurveyEngine.setEmbeddedData("CurrentYear",CurrentYear2);
Alternatively you can change the type of embedded variable to Date (see screenshot below). By doing this you can see this variable for breakdown options of reports.





!

Leave a Reply