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
Question

I have an ED field with a date, how do I make a new ED field with just the year from that date?

  • September 24, 2018
  • 4 replies
  • 77 views

Forum|alt.badge.img+5
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?

4 replies

SaurabhPujare_Ugam
QPN Level 5 ●●●●●
Forum|alt.badge.img+18
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

PeeyushBansal
Level 6 ●●●●●●
Forum|alt.badge.img+43
  • Level 6 ●●●●●●
  • September 25, 2018
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];`

MohammedAli_Rajapkar
QPN Level 5 ●●●●●
Forum|alt.badge.img+20
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);

YASH1T
QPN Level 2 ●●
Forum|alt.badge.img+6
  • QPN Level 2 ●●
  • September 25, 2018
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. !