Questions with date/time responses
When a question requires a date, a time, or a date and time as a response, use the following syntax.
Syntax
<question_name> "<text>" date [[<range>]];
Parameters
<question_name>
The question name.
<text>
The question text.
<range>
(Optional.) A range of dates and times which are accepted as responses. If you omit this parameter, any date and time between 0:00:00 on 1 January 100 and 23:59:59 on 31 December 9999 is accepted.
Example
The interviewing program displays the question followed by a box in which the respondent can type an answer of up to 20 characters:
Date question
Formats for dates and times
Dates can be written using letters or numbers for the month, and / (slashmark) or – (hyphen or dash) as the separator. Years can be entered using two or four digits.
Here are some examples of the more common date formats:
Format | Example |
---|
dd–monthname–yyyy | 31–December–2023 |
dd–mmm–yyyy | 31–Dec–2023 |
mm/dd/yy | 12/31/23 |
yyyy/mm/dd | 2023/12/31 |
If you use the numeric date format and you enter the date as dd/mm/yy (European notation), the date is treated as if it were mm/dd/yy, so 01/04/23 is always 4 January 2023, never 1 April 2023.
Times can be specified in 12-hour format as hh:mmam or hh:mmpm, or in 24-hour format as hh:mm.
Whichever methods you use for writing dates and times, make the specification unambiguous to anyone who reads the script. If you are unsure who else might read the script, use letters rather than numbers for months.
When respondents answer a date question, the way in which they must enter dates is determined by the locale/culture/language setting of the interview. For example, if the interview language is set to en–US, respondents must enter dates in the US format (mm/dd/yy or equivalent). If the interview language is set to en–UK, respondents must enter dates in the British format (dd/mm/yy or equivalent).
Date and time ranges
Questions might define just dates, just times, or dates and times. If you specify a date range only, the interviewing program accepts any time on any date within that date range. If you specify a time range only, the interviewing program accepts any date as long as the time is within the given range. If you specify a time and a date, the interviewing program only accepts responses where both the time and the date are in the given range. When you specify a date and time, the date must be before the time and must be separated from it by a space.
You can specify date and time ranges in any of the following formats:
A range of values
date ["<from_date>".."<to_date>"];
For example:
Dob "Please enter your date of birth"date ["1-Jan-1906".."31-Dec-2016"];
Any date in the given range is acceptable as a response.
Here is an example that uses a time specification:
TimeBooked "What time was your table booked for?"
date ["06:00pm".."11:00pm"];
Respondents can enter any time between 6pm and 11pm. These times can be entered in 12-hour or 24-hour format.
Here is an example with dates and times:
ConsultantTime "And when was your appointment with the research consultant?"
date ["2-Jan-24 09:00am".."31-Jan-24 05:00pm"];
An open-ended range
date ["<from_date>"..];
or:
date [.."<to_date>"];
A start date with no end date has an implied end date of 31 December 9999; an end date with no start date has an implied start date of 1 January 100. For example:
ExpiryDate "When does your driver's license expire?" date ["31-Dec-2024".. ];
A list of single values or ranges
To specify a list of single dates and/or times or date/time ranges, type:
date ["<date_time_1>", "<date_time_2>"," ... "<date_time_n>"];
where <date_time_1> to <date_time_n> are single dates, single times, or date/time ranges.
For example:
TourTime "When would you like to take the special tour?"
date ["2-Jan-25 09:00am".."15-Jan-25 05:00pm",
"16-Jan-25 01:00pm".."31-Jan-25 07:00pm"];
Exclusive values
To exclude specific dates or times from a range, type:
date ["<range_1>"[, ..."<range_n>"] ^<exclude>];
where:
▪<range_1> to <range_n> define the overall valid date/time range for the question.
▪<exclude> is a date, time or date/time range within the overall range specification that is not valid. To exclude more than one date, time, or range, enter each one separately, preceded by a ^ symbol and separated by commas.
For example:
CollectDate "When would you like to collect the documents?"
date ["1-Dec-25".."31-Mar-26",^"25-Dec-25".."26-Dec-25",
^"28-Mar-25"];
Although you can specify a date and time range, you cannot force respondents to enter a date and a time. If a respondent enters a date without a time, the interviewing program assumes that the respondent means the current time and will accept the response as long as the current time falls within the acceptable range for the question. Similarly with dates. If the respondent enters a time but no date, the interviewing program assumes the current date and accepts the response as long as the current date is within the valid range. All responses appear in the case data as a date and a time.
See also