All docs
20.1 (EAP/Beta)
The page you are viewing does not exist in version 19.1. This link will take you to the root page.
The page you are viewing does not exist in version 18.2. This link will take you to the root page.
The page you are viewing does not exist in version 18.1. This link will take you to the root page.
The page you are viewing does not exist in version 17.2. This link will take you to the root page.

Date Range Parameters

  • 4 minutes to read

This document describes how to create a date range parameter and filter report data by the specified dates.

Design Time

Perform the steps below to add a date range parameter to a report.

  1. Switch to the Field List and right-click Parameters. Select Add Parameter from the context menu.


  2. Specify the options below in the invoked Add New Parameter dialog and click OK.

    • Name - the parameter's name;
    • Description - the parameter's description displayed to users;
    • Type - the parameter's data type. Set it to Date to create a date range;
    • Range Value - enable this option to create a date range.


  3. The dateRange parameter appears in the Field List and includes the inner dateRange_Start and dateRange_End parameters. Select the dateRange parameter and switch to the Property Grid to specify the inner parameters' default values.


    The Value property allows you to specify a static default value. Use the ValueExpression property to specify a dynamic default value. Click the ValueExpression's ellipsis button and specify an expression in the invoked Expression Editor.


  4. Use the start and end parameter names in the report's FilterString to filter data by the created date range. Select the report, click the FilterString's ellipsis button in the Property Grid and construct the filter string in the invoked FilterString Editor.



    The start and end parameter values store the selected day's midnight time. For instance, if a user chooses 10/15/2019, the DateTime value is 10/15/2019 12:00:00 AM. If your date fields include non-midnight time, records for the end date 10/15/2019 are excluded from a report. Use the GetDate() function in the FilterString Editor to include data for the 10/15/2019 date.

When users switch to Print Preview, the Parameters panel displays the date range parameter. After a user submits a start and end date, a report document is displayed with filtered data.


The code sample below illustrates how to create a date range parameter in a report, and to filter report data by the specified date range.

using DevExpress.XtraReports.Parameters;
using DevExpress.XtraReports.Expressions;
// ...
XtraReport1 report = new XtraReport1();

// Create a date range parameter.
Parameter myDateRange = new Parameter();
myDateRange.Name = "myDateRange";
myDateRange.Description = "Date Range:";
myDateRange.Type = typeof(System.DateTime);
RangeParametersSettings myDateRangeSettings = new RangeParametersSettings();

// Specify the start date and end date's default values.
myDateRangeSettings.StartParameter.Name = "MyDateRangeStart";
myDateRangeSettings.StartParameter.ExpressionBindings.Add(new BasicExpressionBinding("Value", "AddDays(Today(), -7)"));
myDateRangeSettings.EndParameter.Name = "MyDateRangeEnd";
myDateRangeSettings.EndParameter.ExpressionBindings.Add(new BasicExpressionBinding("Value", "Today()"));
myDateRange.ValueSourceSettings = myDateRangeSettings;

// Filter report data by the specified date range.
report.FilterString = "GetDate([OrderDate]) Between(?MyDateRangeStart,?MyDateRangeEnd)";

Related API

Parameter Class

Parameter.ValueSourceSettings Property

RangeParametersSettings Class

Customize Predefined Ranges

You can customize the set of predefined date ranges. This set is stored in the RangeParameterEditorOptions static class and is available in all date range parameter editors when they are displayed in Print Preview.



This code is in effect for WinForms and WPF End-User Reporting Applications only.

using DevExpress.XtraReports.Parameters;
using DevExpress.XtraReports.Expressions;
// ...
// Remove all predefined ranges and add two new date ranges.
RangeParameterEditorOptions.RegisterDateRange("September", () => new DateTime(2019,9,1), () => new DateTime(2019,9,30));
RangeParameterEditorOptions.RegisterDateRange("October", () => new DateTime(2019,10,1), () => new DateTime(2019,10,31));