# Date Range Input Control for Build Your Own Reports

Date ranges allow the user to enter one date and time or a range of dates and times.

## Examples

### Last N from current time

Allows the user to enter the number of specified time units to filter report data. For example, last 7 days from current time. This image is an example of the Last N from current time date range in a report:

### Settings

To display the Last N from current time date range, configure the following settings on the Add Report Input dialog box.

Setting | Selection
--- | ---
Input Variable | The name you will use as a parameter in the report query.
Display Name | Then name that will appear as a label for the input in the report.
Input Variable Type | DateRange
Input Control Type | DateRange
Hide Input | Cleared
Required | Optional
Options | Last N from current time
Allowed Units | Minutes Hours Days Weeks Months Years

The following image is an example of the configured settings.

The following syntax is an example query for the duration parameter of the date range

    where startdate >=@duration_from and enddate <= @duration_to

### Next N

Allows the user to enter the number of specified time units to filter report data. For example, Next 3 Months. Use input for trending reports. This image is an example of the Next N date range in a report:

### Settings

To display the Next N date range, configure the following settings on the Add Report Input dialog box.

Setting | Selection
--- | ---
Input Variable | The name you will use as a parameter in the report query.
Display Name | Then name that will appear as a label for the input in the report.
Input Variable Type | DateRange
Input Control Type | DateRange
Hide Input | Cleared
Required | Optional
Default Value | 3
Options | Next N
Allowed Units | Minutes Hours Days Weeks Months Years

The following image is an example of the configured settings.

The following syntax is an example query for the duration parameter of the date range

    where startdate >=@duration_from and enddate <= @duration_to

### Previous complete N

Allows the user to enter the number of specified time units to filter report data. For example, Previous 7 days. This image is an example of the Previous complete N date range in a report:

Settings

To display the Previous complete N date range, configure the following settings on the Add Report Input dialog box.

Setting | Selection
--- | ---
Input Variable | The name you will use as a parameter in the report query.
Display Name | Then name that will appear as a label for the input in the report.
Input Variable Type | DateRange
Input Control Type | DateRange
Hide Input | Cleared
Required | Optional
Options | Previous complete N
Allowed Units | Minutes Hours Days Weeks Months Quarters Years

The following image is an example of the configured settings.

The following syntax is an example query for the duration parameter of the date range

    where startdate >=@duration_from and enddate <= @duration_to

### Custom Range With No Default Value

Allows the user to enter a Start Date and End Date from a calendar to filter the report data. This image is an example of a custom date range in a report:

### Settings

To display a custom date range, configure the following settings on the Edit Report Input dialog box.

Setting | Selection
--- | ---
Input Variable | The name you will use as a parameter in the report query.
Display Name | Then name that will appear as a label for the input in the report.
Input Variable Type | DateRange
Input Control Type | DateRange
Hide Input | Cleared
Required | Optional
Default Value | Blank
Options | Custom Range
Allowed Units | All cleared

The following image is an example of the configured settings.

###

The following syntax is an example query for the duration parameter of the date range

    where startdate >=@duration_from and enddate <= @duration_to

### Custom Range With A Default Value

You can also configure a custom date range with a default value, such as the current day, by using PnYnMnDTnHnMnS from the XSD (XML Schema Definition) Duration data type. This image is an example of the custom date range with a default value in a report:

Settings

In this example, the default date and time is today's date, two hours before the current time. Configure the following settings on the Edit Report Input dialog box:

Setting | Selection
--- | ---
Input Variable | The name you will use as a parameter in the report query.
Display Name | Then name that will appear as a label for the input in the report.
Input Variable Type | DateRange
Input Control Type | DateRange
Hide Input | Cleared
Required | Optional
Default Value | -PT2H
Options | Custom Range Include Time Selection
Allowed Units | Minutes Hours Days Weeks Months Years

The following image is an example of the configured settings.

The following syntax is an example query for the duration parameter of the date range

    where startdate >=@duration_from and enddate <= @duration_to

### Custom Range Example Query

To use the custom date range input, create a parameter for the date range input. Configure the following settings on the Edit Data Set dialog box:

Setting | Selection
--- | ---
Parameter | Input variable that you configured in the Edit Report Input dialog box.
Type | DateRange
Multi | Cleared
Required | Cleared
Value | =input.duration

The following image is an example of the configured settings.

Then, add the parameter as part of a where clause in the report query in the Query box on the Edit Data Set dialog box:

    where startdate >=@duration_from and enddate <= @duration_to

The following image is an example of the configured settings.

### Include Time Selection

When a custom date range is selected, allows the user to also select a specific time from a list. This image is an example of a custom date range with a Time Selection in a report:

Settings

To display a custom date range with a Time Selection, configure the following settings on the Edit Report Input dialog box.

Setting | Selection
--- | ---
Input Variable | The name you will use as a parameter in the report query.
Display Name | Then name that will appear as a label for the input in the report.
Input Variable Type | DateRange
Input Control Type | DateRange
Hide Input | Cleared
Required | Optional
Default Value | Blank
Options | Custom Range Include Time Selection
Allowed Units | All cleared

The following image is an example of the configured settings.

The following syntax is an example query for the duration parameter of the date range

    where startdate >=@duration_from and enddate <= @duration_to

## Associated Input Variables

- Date Range

×

Loading...