> For these statements, please tell me whether the statement was often true, sometimes true, or never true for you in the last 12 months—that is, since last (name of current month).
Essentially, I just want to insert the current month in place of those parentheses. I figure the way to do this is with piped text, but the only date options I am finding that way include the day and year, not just the month name.
Any suggestions on the most efficient way to insert just the current month name?
```
Qualtrics.SurveyEngine.addOnload(function() {
var curDate = "${date://CurrentDate/FL}";
jQuery(".monthName").text(curDate.substr(0,curDate.indexOf(" ")));
});
```
Then add this html anywhere you want the name of the current month:
```
<span class="monthName"></span>
```
Step1: Make a embedded data(month) in survey flow before the question
Step2: Paste the below code in the one previous question (js option) to the required question.
const monthNames = ["January", "February", "March", "April", "May", "June",
"July", "August", "September", "October", "November", "December"
];
const d = new Date();
var n=monthNames[d.getMonth()];
Qualtrics.SurveyEngine.setEmbeddedData( 'month', n );
Step3: Now pipe embedded data "month"
Ended up using TomG's code, since we might end up translating the survey in the future. Works perfectly, as far as I can tell.
I think have a mistake somewhere. Attached is a working .qsf that you can compare to what you have.
> @TomG, I got it working. What is happening on both my version and your QSF file is that after it is working, if I go back into the rich content editor for that question the HTML disappears
Yes, don't use the Rich Content Editor on questions with HTML. If you have HTML in a question it is best to always edit it in HTML View (even editing in Normal View can sometimes have unintended consequences).
> @TomG how can I adjust the code to always show the previous month? Thanks!
Change the date pipe to ${date://OtherDate/FL/-1 month}
https://www.qualtrics.com/community/discussion/comment/17910#Comment_17910Replace FL with m (2 digit month). If you don't want a 2-digit month, I don't know any alternatives. Qualtrics used non-standard date formatting that isn't documented anywhere. If there are other month only formats, I don't know what they are (m isn't documented either, I just happen to know about it).
TomG
I'm hoping this is the Easy part: I need to get both the current month and the month after to be available to pipe into the survey. I can currently do the current month with your script in the header, but I can't seem to get a FL/month+1 to work.
Probably the Harder part: If it's possible, I have a question that asks which month someone leaves our company (if it's not the current month as above). It would be useful to pipe a month+1 and a month-1 based on that response into the survey. Is that even possible!
Thanks in advance for any help you can provide.
Geoff.
GeoffreyJ ,
Pipe for the next month is ${date://OtherDate/FL/+1 month}
The second part is doable. I would probably use moment.js to parse the input into a date and calculate the other months.
Thanks for your swift comment.
I've got the current month script working, but I can't get it to work with the month+1 script. My current script looks like this:
I've also tried it as two separate scrips
Any advice?
You need a space between 1 and month: ${date://OtherDate/FL/+1 month}
Also + isn't a valid character in a class name.
TomG:
Do you happen to know the syntax for displaying only the current four-digit year (the four-digit year for the current date)? I also want to know if it will work if I tell it "-1 year."
https://community.qualtrics.com/XMcommunity/discussion/comment/42205#Comment_42205Current Year:
${date://CurrentDate/Y}
One year ago:
${date://OtherDate/Y/-1 year}
Here is how I did it...
Pipe the text into your statements and...
Tada!
Leave a Reply
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.