logo SmartSurvey / Scripting Docs
Back to Docs
Question Type
14 Date Date/Time *DATE

Captures a calendar date from the respondent using a date picker. The response is stored internally as an integer in YYYYMMDD format (e.g. 20260908 for 8 September 2026). Use datevalueof[] to extract the year, month, or day component individually for use in come-logic, check conditions, or validation rules.

Type ID 14
Directive *DATE
Category Date/Time
Script Definition
script definition (.q)
-- Basic *DATE: respondent selects a date from a calendar picker.
*QUESTION Q14 *DATE
Q14. When did you last purchase this product?

-- Restricting the selectable date range using *MIN and *MAX:
-- *MIN sets the earliest allowed date; *MAX sets the latest.
-- Both values must be in YYYYMMDD integer format.
*QUESTION Q14 *DATE *MIN 20240101 *MAX 20261231
Q14. When did you last purchase this product?
Use in Expressions
expressions
datevalueof[Q14,Y]>=2024          -- purchased in 2024 or later
datevalueof[Q14,M]=12             -- purchased in December
datevalueof[Q14,D]<=15            -- purchased in the first half of the month
datevalueof[Q14,Y]=2025 & datevalueof[Q14,M]>=6   -- purchased from June 2025 onwards
The date is stored as a YYYYMMDD integer. Use datevalueof[Qx,Y] to extract the year, datevalueof[Qx,M] for the month (1–12), and datevalueof[Qx,D] for the day (1–31).
Why *MIN and *MAX on a date? They restrict the calendar picker to a valid fieldwork window, preventing respondents from entering implausible dates such as a purchase date in the future or decades in the past. Values must be in YYYYMMDD format (e.g. *MIN 20240101 *MAX 20261231).
Combine datevalueof[Qx,Y] and datevalueof[Qx,M] in come-logic to route based on recency. For example, route recent purchasers (within the last 6 months) to a follow-up section and lapsed purchasers elsewhere.
Do not compare a *DATE response directly using Q14=value. Always use datevalueof[] to extract the required component before comparing.
Related