Display name of weekday only | XM Community
Skip to main content

Hi,
I have a question where I'm piping in today's date strictly for the name of the weekday (i.e. "Tuesday"). Using the traditional, "${date://CurrentDate/DM}" gives me "Tuesday, September 21" but I only want it to say "Tuesday" and changing the DM to E doesn't work.
Can someone help me?

  1. Create a embedded data text of Current Date.

  2. Create an If statement to see if Current Date contains Sunday, if it does set Day of Week embedded to Sunday.

  3. Repeat step #2 for all the days of the week.

image.png


Hi @MSobotta 

 

Great answer.  Do you have a solution for a embedded field of a past date?  eg. we have a field that is imported at the time of a survey response being recorded of a past date.  Is there a way to retrospectively create a custom field (in the D&A tab) that will convert that date to a day.  Our field is called holidayStartDate and the date is written in the form of 2023-09-09 (, ie US format so that it’s recognised by Qualtrics as a date).

 

Using the Bucket field for every day would be a solution but not really something I’d like to consider as it would be a mammoth task to assign and group every date - unless there is a quicker way to setup a bucket field (eg import a csv file but I don’t think that’s possible).  Similarly you might be able to import a setup file in a dashboard dataset and import a file but again this will need to be updated every so often and I’m not sure that it would be available for statsiq work?

 

Thanks in advance

 

Rod Pestell


Just to add to this, I was looking into using a regular event on a survey and using a simple code task to get the weekday name but how you then join or merge that into the existing data I’m not sure how you’do do this….

 

To start - this is the code task that will create the weekday

function codeTask() {

//https://stackoverflow.com/questions/24998624/day-name-from-date-in-js

var dtDay = "${e://Field/Holidaystartdate}"
//note if you don't put the other field in double quote it returns a differnt day!! lol

//dtDay = "2023-05-01"

var date = new Date(dtDay);
var dayname = date.toLocaleDateString("en-US", { weekday: 'long' });

return {
dayName: dayname
}
}

 

The only way to retrospectively make a change as I understand is to create a scheduled workflow > extract response from survey (chosen columns: ResponseID, Holidaystartdae) > CodeTask (as above) > ????? what I do then I’m not sure.

 

The extract response from survey requires a destination so it sounds like I’d have to export it to say a csv file but if you choose eg. ‘Load data in SFTP’ it will only let you select the extract task and not the code task.

 

This is the point I get stuck at as I want to merge the extract and the code task together before saving to csv and/or ideally adding it back into the existing data.

 

Hope you can help

 

Thanks

 

Rod Pestell

 


Leave a Reply