Date
The date type defines a question that requires a date, a time, or a date and time as the response. The response data is stored using the Date data type, which consists of a floating-point number that represents dates ranging from 1 January 100 to 31 December 9999 and times from 0:00:00 to 23:59:59.
Syntax
For clarity, each item is shown on a separate line, and optional items are indented. See also
Syntax conventions.
field_name [ "field_label" ]
[ [ <properties> ] ]
[ <styles and templates> ]
date [ [ range_expression ] ]
[ <categories> ]
[ <codes> ]
[ expression ("expression_text") ]
[ ( initialanswer | defaultanswer ) (date_value) ]
[ <axis> ]
[ <usage-type> ]
[ <helperfields> ]
[ nocasedata ]
[ unversioned ]
Parameters
For
<axis>,
<usage-type>,
<helperfields>,
nocasedata, and
unversioned, see
Common parameters.
range_expression
To specify:
|
Syntax:
|
Any date value
|
Field date;
|
|
Example:
Departure date;
|
|
Any date between 1 January 100 and 31 December 9999 is valid.
|
A range of values
|
Field date [ n1 .. n2 ];
|
|
Example:
Working date ["12-July-02 8:00am".."11-July-03 6:00pm"];
|
|
Any date between 8:00am on 12 July 2002 and 6:00pm on 11 July 2003 inclusive is valid.
|
A minimum to undefined max.
|
Field date [ n1 ..];
|
|
Example:
Expiry1 date ["12-July-01"..];
|
|
Any date after 12th July 2001 is valid.
|
From undefined min. to max.
|
Field date [.. n1 ];
|
|
Example:
Expiry2 date [.."07-12-05"];
|
|
Any date up to 12th July 2005 is valid.
|
Single values
(Not supported in Data Model 2.8.)
|
Field date [ n1 , n2 , n3 , n4 ...];
|
Example:
Leaving date ["12:00am", "1:00am", "2:00am"];
|
Times 12:00am, 1:00am, and 2:00am are valid.
|
Several different ranges
|
Field date [ n1 .. n2 , n3 .. n4 ...];
|
|
Example:
Workday date ["8:00am".."12:30pm", "1:00pm".."6:00pm"];
|
|
Any time between 8:00am and 12:30pm inclusive or between 1:00pm and 6:00pm is valid.
|
Exclusive values
|
Field date [^ n1 .. n2 ];
|
|
Example:
DepartureDate date ["1-Dec-03".."1-Feb-04", ^"25-Dec-03".."26-Dec-03"];
|
|
Any date between 1 December 2003 and 1 February 2004 except 25 and 26 December 2003.
|
If you enter the month as a number, use one of these formats:
▪United States English date formatting (in which the month is specified before the day). For example, in this format 07-12-05 represents 12th July 2005.
▪The international standard YYYY-MM-DD format, where YYYY is the year, MM is the month between 01 (January) and 12 (December), and DD is the day (between 1 and 31). For example, in this format 2005-07-12 represents 12th July 2005.
<categories>
Use the optional categories list to specify that the question will be presented as a single-response categorical question. If a category is selected, the value of the response will be the factor value assigned to that category by the factor keyword. Therefore, all categories should be assigned a factor value, which must always be specified in the format yyyy/mm/dd, regardless of the regional settings on your computer. In this example, the value of YearAccountOpened is 1st January 2005, or 1st January 2004, depending on which of the two categories is selected:
YearAccountOpened "In which year did you open your account?" date
{
thisyear "2005" factor("2005/01/01"),
lastyear "2004" factor("2004/01/01")
};
For more information about defining a category list, see
Categorical.
<codes>
The optional codes list is used to define special responses for the question. A code list is defined in the same way as a category list and is typically used to include Don't Know, No Answer, or Refused to Answer responses, which are identified by the DK, NA and REF keywords respectively. For example, the following defines a numeric question called Birthday that has No Answer and Refused to Answer responses. Special responses are automatically marked as exclusive, meaning that they cannot be combined with any other answers. Only a date, No Answer, or Refused to Answer are acceptable responses:
Birthday "Date of birth" date codes (
{
NoAnswer "No answer" NA,
RefusedToAnswer "Refused to answer" REF
} );
When using the DK, REF or NA keywords, you can use a hyphen (-) as the category name to specify that the category name should be the same as the keyword.
expression
The optional expression keyword is used to create a variable using a formula defined in expression_text. Generally you use this feature to create a derived variable that is based on one or more other variables. For example, the following creates a variable containing a first birthday date, which is calculated using the value of the Birthdate variable.
FirstBirthday date expression("dateadd(Birthdate, ""yyyy"", 1)");
expression_text must be an expression that is supported by the UNICOM Intelligence Data Model and can optionally include functions from the
UNICOM Intelligence Function Library, such as in the example above which uses the DateAdd function. Double quotation marks (") must be escaped using a second double quotation mark (for example,
""yyyy""). Check the syntax and spelling carefully, because the expression is stored without being validated. See
Expression evaluation for more information.
initialanswer and defaultanswer
You can optionally specify either an initial answer or a default answer to the question. An initial answer can be seen by the respondent, whereas a default answer can not be seen. If either type of answer is defined, the respondent does not need to answer the question. For example:
NewsItem "On what date did you see the news item?" date
initialanswer("07-May-2003");
If a default answer is not accepted when you run the interview script, in other words, the message “Missing Answer(s)” is displayed, see
mrScriptMetadata FAQs.
Remarks
For more information about writing Date questions in interview scripts, see
Questions with date/time responses.
Example
This example defines a date question called PurchaseTime with the text “At approximately what time did you purchase our product?” for which any time between 6:00am and 6:00pm, “Don't Know”, or “Refused to Answer” are valid responses:
PurchaseTime "At approximately what time did you purchase our product?"
date ["06:00" .. "18:00"]
codes (
{
- "I'm not sure" DK,
- "I'd rather not tell you" REF
} );
See