Analysing date responses
Dates are analysed in a number of ways as follows:
- Dates are categorised as falling in particular years, months or weeks of the year, or on particular days of the week.
- The difference between two dates can be calculated, such as calculating a respondent’s age. These can be categorised or grouped into appropriate ranges or used in the production of descriptive statistics.
Date formats
The software supports a wide range of date formats. All dates are based on the Gregorian calendar.
Day
The day number must appear in the range 1 to 31, with optional leading zeros. For example, 01, 02 are acceptable. Checks are made on the validity of a day number for the given month. For example, 31 September will be invalid. In the case of the month of February, the calculations also check whether the year is a leap year.
The day number can appear before or after the month, e.g. 1 Jan or Jan 1.
You cannot use the day suffixes such st, nd, rd, th, unless you apply a suitable date pattern to the variable.
The system settings determine the local rules for dates, such as the US standard of Month/Day/Year. Consequently, 01/05/97 will be calculated as January 5th 1997 in the US and May 1st 1997 in the UK (the computer date settings control these formats).
The characters, full stop (.), a hyphen (-) or a slash (/) separate the month, day and year. A space is used when the month is a word.
In the special case where the month name is given before the day number, a comma can be used to separate the day and year, e.g. January 5,1997
Month
The month can appear in full, e.g. January, or abbreviated to the first 3 characters, e.g. Jan, or as a number, e.g. 01.
The only exceptions to the 3 character abbreviation rule are July which can be Jul or Jly, and September which can be Sep or Sept.
The characters, full stop (.), a hyphen (-) or a slash (/) separate the month, day and year. The space character separates the month from the rest of the date if it is in word format.
Year
The year number has two formats available, either the last two digits, e.g. 97, or the full year, e.g. 1997. The characters, full stop (.), a hyphen (-) or a slash (/) separate the month, day and year.
When a year has only two digits, the default sets the year between 1930 and 2029 inclusive. In this way, 97 represents the year 1997, 00 represents 2000, and 29 represents 2029. Update the default year range by opening the Data Entry Tailoring dialog, using the Tailoring | Data Entry menu item. The Dates section contains the Date format and 2 Digit Years fields, which sets the default year range.
Date functions
When defining dates, there are a number of functions that can perform calculations and tests on the dates. The function names are not case sensitive and can be written in uppercase or mixed case.
Function | Description |
year | Gives the year in which the date occurs. Note that the result is always the year in full, that is, even though the date was recorded as being in 06, the year function returns 2006. |
month | Gives the month number in which the date occurs. |
month name | Gives the name of the month in which the date occurs. |
day | Gives the day of the month in which the date occurs. |
weekday | Gives the day of the week on which the date occurs. Monday is weekday 1 and Sunday is weekday 7. Dates which fall on the weekend are those where weekday is greater than 5, similarly, dates which fall in the week are those where weekday is less than 6. |
weekday name | Gives the name of the day of the week on which the date occurs. |
today | Used as a variable, returning the current date as set on the computer. |
Examples
Date functions are useful in filter expressions to return a group of data responses based on a date, for example all responses completed in a particular month or year. Filters are available in analyses, reports and when looking at responses in the data entry window.
Here are some examples of date filters using the date functions:
- ID.Date year=2023 gives responses for everyone who responded in 2023
- ID.Date year=Today year gives responses completed this year
- VisitDate Month = Today Month gives responses where respondents visited this month.
- VisitDate Month = Today Month AND VisitDate Year = Today Year returns responses where respondents visited this month in the current year, which you can use if your survey runs over a number of years
- VisitDate Month = 1 gives responses where respondents visited in January
- VisitDate Month name = “January” also gives responses where respondents visited in January
- VisitDate day = 1 gives responses where respondents visited on the first day of the month
- VisitDate weekday = 1 gives responses where respondents visited on Monday
- VisitDate weekday name = “Monday” is an alternative filter that also gives responses where respondents visited on Monday
- ID.Date weekday = (1 TO 5) gives responses completed on a weekday from Monday to Friday
- ID.Date weekday = (6 TO 7) gives responses completed on a weekend from Saturday to Sunday
- ID.Date weekday > 6 is an alternative filter which also gives responses completed on a weekend