So, you want to compare today's date to a date entered in a response. Or you want to know if the date entered is more than one month from today. Or compare the start date to the end date entered to ensure they didn't mistakenly put in a wrong date.
It's all about validation. Qualtrics can do this natively IF the dates entered are all the exact same format.
In survey flow I created a few embedded data fields to hold some data
1. Is today’s date – the date the respondent is filling out your survey
2. Tomorrow shows how to increment by one day. NOTE: %20 is html for a space
3. Thirty days from now adds thirty days to today’s date
4. Thirty days ago subtracts 30 days from today’s date
I can show the data...
I can even ask for a date input (has to match the format)
And then I can do a comparison between what was input and what I already have to control my display logic.
My only issue/problem to solve now is how can I force the proper format needed (mm/dd/yyyy - with NO leading 0s for months or days)? I need help with REGEX that will validate no leading zeros for mm nor dd.
might as well also ensure that the day isn't greater than 31 and the month not greater than 12
Alright! Thanks to Dave B (coworker), I believe we also found REGEX to:
- check that there is no leading 0 on days
- check that there is no leading 0 on months
- ensure days don't go over 31 and months don't go over 12
^([1-9]|1[012])\\/([1-9]|[12][0-9]|3[01])\\/\\d{4}
This is incredibly helpful content - I know so many users have struggled with date calculations in the past. Thank you so much for sharing this thoughtful solution
Thanks AmaraW I enjoy finding "native" solutions without coding. Coding runs into issues when the source controls change (javascript seems to change weekly) or if it collides with controls on the system or platform.
Looks like this no longer works? Anyone else noticing issues with comparing dates now? I'm going to look into creating a Julian-type value and compare as a number...
And now it's back to working!
It's working without designating Text Set
And within the project, the display logic works properly
(Adult Pads 1 Exp Date - was a text entry field using date format yyyy/mm/dd). The constant is the date format AND that you compare a embedded data field (name) to an embedded data field (code)
Hi All, has there been any progress in being able to calculate the difference between two dates within the survey flow yet? I would much prefer to do it that way than have to roll out some java script code.
At present no matter how you present the date it always takes it too literally in the calculation
eg yyyy-mm-dd will subtract the year, month and day numbers first. Likewise yyyy/mm/dd divides them
Example in the survey flow:
so a date of 2023/01/24 and todays date (2024/10/24) as created by Qualtrics. Gives you an outcome of 76.50705 which is calculated by dividing the numbers and then subtracting them.
I’ve tried changing the field type from text to date etc. but that makes no difference.
Funnily enough when using the display logic in a survey it will recognise them as a date and know whether a date (I’ve only tried yyyy-mm-dd format) is greater or less than another date.
Is there a product idea out there to upvote on this if there is no solution yet?
Thanks
Leave a Reply
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.