Hi everyone,
I am carrying a survey that asks respondents for a certain time, and then get responses based on that time. How can I do this? My intuition is that I could do that by converting numerical variables into a "date" kind of variable, but I'm not sure how to do this.
Let's assume, as an example, the following two questions:
Q1: At what time do you have to be at work?
[Hypothetical response: 11:50 AM]
(I am planning on using a Drill Down question for this)
Q2: Would you take the following trip?
Leave: Q1_time + delay - traveltime
Arrive: Q1_time + delay
Cost: $5
(Assume Q1_time, delay and traveltime are predefined variables.)
Displayed text:
Leave: 11:43 AM
Arrive: 12:05 PM
Cost: $5
I cannot simply use $e{MINUTES + 15} because that would return 11:65 AM. I know it is possible to operate on "date" variables (see "Piping Date / Time" here), but I'm not sure how I can convert my numerical variables to a certain time.
Thanks!
Page 1 / 1
You need separate math operations (branching logic) if MINUTES is equal to or greater than 60. In which case HOURS + 1 and MINUTES - 60, combine in time format.
Example o 11:65
11 + 1 (12) | 65-60 (5), 12:05
Note, you will need additional branching logic so that you pipe "05" and not just "5" (12:5).
Example: If MINUTES is less than 10, create embedded data zero=0. Then your MINUTES statement looks like $e{field://zero}$e{MINUTES logic from earlier}. This way you always get 01,02,03, etc. until 10, where "zero" doesn't get created, so the "zero" variable won't show up.
Example o 11:65
11 + 1 (12) | 65-60 (5), 12:05
Note, you will need additional branching logic so that you pipe "05" and not just "5" (12:5).
Example: If MINUTES is less than 10, create embedded data zero=0. Then your MINUTES statement looks like $e{field://zero}$e{MINUTES logic from earlier}. This way you always get 01,02,03, etc. until 10, where "zero" doesn't get created, so the "zero" variable won't show up.
Leave a Reply
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.