Display an answer option after specific date | XM Community
Skip to main content
Hi there,



I want to display a option after 7 dec and one more option should be shown between 7 oct to 10 oct.



I am not sure If I have to create an embedded variable or do this using javascript.



Thanks
Try display logic based on embedded data "Current day/time"
Thank you, I tried but I guess I am doing wrong. Could you please give me an example?
So first of all ON TOP of the survey flow you need to create an embedded data field, let's say "Datenow" and set it to the "Current day/time", this you need to test, as there are differences in date formats that may influence the conditioning.

!

For example, for my test I use this date: ${date://CurrentDate/c} which corresponds to the date in format: 2019-09-04T09:45:23+03:00



Then I put a question and display logic to show the question if the embedded data field value is less than yesterday. In this case I don't see the question

!



If I put the date is less than tomorrow, I see the question when taking the survey

!





With the same logic you can have date ranges when a question would be appearing
Thank you MsIreen for given a perfect example. I really do understand now.



I tried this but taken a different format than yours - 9/4/2019 (format).



I created a embedded variable and assigned to today's date.

!



then I added a display logic to the answer option

!



I changed the logic (greater than and less than) to see if it's working or not. But it doesn't work for me.



Can you please have a look?
> @Deep said:

> Thank you MsIreen for given a perfect example. I really do understand now.

>

> I tried this but taken a different format than yours - 9/4/2019 (format).

>

> I created a embedded variable and assigned to today's date.

> !

>

> then I added a display logic to the answer option

> !

>

> I changed the logic (greater than and less than) to see if it's working or not. But it doesn't work for me.

>

> Can you please have a look?

>

>

>

>



Try the same format that I tried. I couldn't get the one you are using to work either 😉
I tried with your format as well. It still doesn't work 😞
Oh... It may be still slightly different format for you due to the time zone etc. I have checked my format by first submitting a response and then checking how the date looks like in the data set:

!

Then I made the modifications accordingly.
Hi, I have used this format from the piped text -



!



Just to see how it displays:

!



Now applying the logic on the question:

!



It doesn't work for some reason
@Deep



Did you add "timenow" as an embedded data field on top of the survey flow?
Yes - current date I have taken to the format used by you.



https://uploads-us-west-2.insided.com/qualtrics-us/attachment/qc_50d6avl7b2hi.png
> @Deep said:

> Hi, I have used this format from the piped text -

>

> !

>

> @Deep said:

> Yes - current date I have taken to the format used by you.

>

> https://uploads-us-west-2.insided.com/qualtrics-us/attachment/qc_50d6avl7b2hi.png

>

You have different formats: c in screenshot above and SL in screenshot last
!





I tried this as well and other formats as well, it still doesn't work for some reason.
I guess we can't put display logic in that way for "date/time" with embedded data because it will compare two strings not "date\\time" and which could result wrong for some cases.



I would suggest to handle this by js instead.
You can create a date in YYYYMMDD format that is a number, then do a comparison:

```

currentDate = ${date://CurrentDate/Y}${date://CurrentDate/m}${date://CurrentDate/d}

```
Yes, this way it will compare in right manner.
I use a different date format in one of my current surveys and I am easily able to add this as display logic on the choices. The data that I am comparing it to has to be formatted YYYY/MM/DD for this to work however.



Then my logic on the response option is:



Embedded Data, VARIABLE_NAME, Is Greater Than, ${date://CurrentDate/Y%2Fm%2Fd}



Where VARIABLE_NAME = yyyy/mm/dd



${date://CurrentDate/Y%2Fm%2Fd}

I too have been able to compare dates by using only the date (not the time). For Time comparisons I find it works best with Military Time.


I would like to have the current date show up on the first question on a survey.  I have tried to set the default to the DateNow but it does not show when I do  a preview


https://www.qualtrics.com/community/discussion/comment/28879#Comment_28879You can pipe the date directly into the first question in the appropriate format (e.g., ${date://CurrentDate/Y%2Fm%2Fd})
You could also pipe the date into the DateNow embedded field in the survey flow prior to the first question block:
DateNow = ${date://CurrentDate/Y%2Fm%2Fd}
Then pipe ${e://Field/DateNow} into your question text.


Yup, what @TomG said! NOTE: If you also want to use TIME, you pull that in using a different embedded data. And most importantly, if you want to compare times, use military time.
For example - I had a first question be: "Please select a start time and and end time for the permit." I used the current time embedded data for each as default choices. BUT then I did a data check (Display Logic) that did not allow the respondent to go on unless the "end time" was greater than the start time. To do that comparison it only worked if they were both in military time.


Hi mklubeck and TomG
Forgive me following on this threat but I felt it the best place. I was trying to use this method to inject a time in a field in a ticket data field in an update ticket task but it's not working either by piping it in directly or using a code task before. Is there a simple syntax issues or do I need to do something different. ideally I'd like the format yyyy-mm-dd hh🇲🇲ss put in the ticket data field, email task and use in a webservice task to update the embedded field in the survey.

code task attempt (realise code is different to the other two for the date but was just trying different things).
function codeTask() {

// removes any unwanted commas
var TxtSubcategoriesEdit = `${tck://kv/Subcategories}`.replace(/,,+/g, ',').replace(/,$/g, '');

// trying to create a timestamp to use in other tasks (would rather use a pipetext of the date directly however
var DateTime = `${date://CurrentDate/Y}-${date://CurrentDate/Y}-${date://CurrentDate/M} ${date://CurrentTime/MT}`;

return {
result1: TxtSubcategoriesEdit,
result2: DateTime
};


}

in an email task they seem to work as expected, eg: ${date://CurrentDate/Y%2Dm%2Dd}
image.png

However, for some reason that converts it back into British format which is annoying!!
Resulting email recieved
image.png


but in the ticket task it just takes it literally
image.png
This is the resulting field in the ticket after being updated:
image.png
Please can I get some advice on how to create a time stamp (yyyy-mm-dd hh🇲🇲ss) for each type of task?

Thanks

Rod Pestell


Hi Rod_Pestell sorry if you did this already, but did you try creating your embedded data [DateTime] in Survey Flow instead of code? I find that importing the reserved date fields directly doesn't normally work (if I'm remembering correctly) but if you push that same data into an embedded data field in Survey Flow and using that, it worked.


Hi mklubeck
I am doing ticket stuff so working from a survey workflow is not possible. The time needs to be the time that something happens to a ticket.
All the code examples i have used successfully in a survey flow so just assumed it would be possible to use them elsewhere.
In the meantime I've done a quick fix in a code task using the updatedAt piped text and done a dirty quick fix using the .replace command multiple times. It might break though so still trying to find a better and future proof fix.

Thanks

Rod Pestell
Thanks


Leave a Reply