# Date variables

## Date variables

Date variables are a special type of [Selector](<https://help.apteco.com/en/faststats/analysis/selections/using-variables-in-selections/selector-variables/index.md>) variable that FastStats can manipulate in different ways. Date variables can be identified in the System explorer as they have a calendar icon to the left of the variable name.

To create a selection on a **Date** variable e.g. **Booking Date**:

Create a new selection either by:

- Clicking on the **Selection** icon in the **Toolbox**
- Dragging the **Selection** tool from the **Toolbox** onto the FastStats workspace
- Dragging the Date variable to use in the selection directly from the System explorer onto the FastStats workspace

If you used the first or second method above to create a new selection, you will have a blank selection window similar to the one below.

> [!NOTE]
>
> The resolve table has been changed to Bookings.

With the first or second methods:

1. Drag and drop the **Date** variable to use e.g. **Booking Date** onto the New Selection window

You then have a choice as to how you pick which dates to select. You can use dates in a similar way to other [Selector](<https://help.apteco.com/en/faststats/analysis/selections/using-variables-in-selections/selector-variables/index.md>) variables by just picking the days to select from a list. To do this use the **Type** drop down list and select **Ad-hoc Dates**.

This will bring up the **Date Range** Window (below) and you can select which dates to include.

> [!NOTE]
>
> By default, the Full Date is displayed, but the drop-down menu allows you to select and show the dates as weeks, months, quarters, years, etc. This works in the same way as other [zoom or summary variables](<https://help.apteco.com/en/faststats/analysis/selections/using-variables-in-selections/zoom-level-selector/index.md>). A description of the options available can be found at [Create a cube with date and date/time variables](<https://help.apteco.com/en/faststats/analysis/cubes/date-variables/index.md>)

## Date rules

However, it may be more useful to select a set of dates by defining a rule rather than picking lots of individual days. Whilst rules can be used to select absolute date ranges as with the above, they can also be used to define more complex ranges and use relative dates too.

- Choose the **A Date Range** option from the **Type** drop down or any of the predefined date rules (such as Today, This Month, etc).

This will display the **Date Rule** window (below) which allows you to define the dates to be included in the rule.

The **Date Rule** window is split into 4 sections. The first is the **Description** section that allows you to change the default description to be used when listed with any other rules or list of dates (see the screenshot for the final step, below).

The second section is the **Pattern** section and is used to define which dates are selected. By default it is hidden and set to choose every day between the from and to dates. It can, however, be expanded to allow you to change the pattern (see below).

The third and fourth sections are the **From** and **To** sections and are used to define a range over which the pattern will work.

The **Pattern** section has four different displays, depending on which of the Daily/Weekly/Monthly/Yearly radio buttons are selected on the left hand side.

The **From** and **To** sections are then used to define the range over which the pattern will work.

There are a number of options available:

- Earliest: This is the first date that the FastStats system holds.
- Latest: This is the last date that the FastStats system holds.
- 26/01/2007: This allows you to specify an absolute date that will stay the same over time (i.e. the date 26/01/2007 will still be the same tomorrow as it is today).
- Today Forward by 0 Days: This option allows you to specify a relative date that will change depending on the date that the selection is run. The default is for today's date, but you can change the combo box to be one of:

  Today

  This Week

  This Month

  The Year

  Load Date

  Load Week

  Load Month

  Load Year

  First Populated Date

  First Populated Week

  First Populated Month

  First Populated Year

  Last Populated Date

  Last Populated Week

  Last Populated Month

  Last Populated Year

> [!NOTE]
>
> For the **From** range the date chosen will be at the start of the period (i.e. the Monday of the week, the 1<sup>st</sup> of the month or the 1<sup>st</sup> of January of the year). The **To** range uses the end of the period (i.e. the Sunday of the week, the last day - 28<sup>th</sup>, 29<sup>th</sup>, 30<sup>th</sup> or 31<sup>st</sup>, depending - of the month or the 31<sup>st</sup> December of the year).

The **To** range also supports the following options:

- Forward by 10 occurrences.
- Backward by 10 occurrences.

This allows you to pick the first ***n*** times the pattern occurs. This might be from start date for 10 days, from the start date for 10 weekend days or from the start date for 10 2nds of every month.

Finally, when you are happy with your date rule or selected date values, select **OK** and the rule or values will be inserted into the list (as below). You can then:

- Rename the item to have a more meaningful name
- Create more rules or date values by pressing the buttons on the bottom toolbar again

You can also delete the items already created by right-clicking the row in the list and selecting **Delete**.
