Calculating the number of days between two dates is easy as this worksheet shows.

The example we will use is of a vacation questionnaire where we want to find the period of time the respondent has spent on vacation. In addition, there is a requirement to determine the average length of stay by age of respondent and to group the period away into useful bands.

The original questionnaire asked for the date when respondents went on vacation, the date they returned and the age of the respondent.

Step By Step

Step 1

Enter two open ended, date response questions, one for vacation departure date and one for the vacation return date. Then create Q3 using a multiple-choice, single response question to capture respondent’s ages. You can do this easily by using the reference window rereference icon. Now ensure that the data has been input into Snap.
Vacation dep / return dates | Age

Step 2

From the Variables window click on New Variable to create the variable that will contain the formula to work out the number of days between the two dates.
Variable Details dialog example | q2-q1

Step 3

Enter the following information:

Name: DaysAway
Label: Days Away on Vacation
Type: Derived
Response: Quantity
Text: Days Away on Vacation

In the Values column, in the same row as Valid, type Q2-Q1. This will calculate the amount of days between holiday departure date and holiday return date.

Creating a table to show the average length of stay by age

This is one way that you could display the results of the data.

Step 1

Click on Results Table results table icon.
Results Definition dialog

Step 2

Change the Calculate field from Counts and Percents to Means and Significances.

Step 3

Type the Q3 into Analysis and DaysAway into the box to the right of Means & Significances.

Step 4

Click OK to show results.
Length of stay by age

Grouping the number of days on vacation into useful bands.

This will categorise the data so that a table or chart can be produced.

Step 1

From the Variables window multiples icon click New Variable plus | add to create the variable to show the amount of days from the departure date to the return date.

Step 2

Enter the following information:

Name: Length
Label: Length of Vacation
Type: Numeric
Response: Single

Step 3

Click in the Label field for Code 1 and type out the first answer e.g. 1 to 3 days. Press Tab on the keyboard, this will jump to the Values column. In this column Snap needs to know what numbers are to be displayed in this answer e.g. 1 to 3. Follow the same procedure to create categories for 4 to 6 days, 7 to 10 days and over 10 days.
Variable Details dialog example | 1-3 days

Step 4

Click on Toggle Details Design mode button and change Source to DaysAway.

Step 5

Click Keep changes Save to save.

Step 6

Click on Results Table results table icon or Results Chart results icon to show the results definition window.

Step 7

Type the word Length into Analysis. Click OK to show results.
Length of Vacation

If there is a topic you would like a worksheet on, email to snapideas@snapsurveys.com