Back to Devexpress

DateTimePeriod Class

dashboard-devexpress-dot-dashboardcommon-cfea2e21.md

latest9.4 KB
Original Source

DateTimePeriod Class

A date-time period that is used to select a predefined range in the Range Filter and Date Filter items.

Namespace : DevExpress.DashboardCommon

Assembly : DevExpress.Dashboard.v25.2.Core.dll

NuGet Package : DevExpress.Dashboard.Core

Declaration

csharp
public class DateTimePeriod :
    IXmlSerializableElement,
    IDateTimePeriodLimitOwner,
    INameContainer,
    INamedItem,
    ISupportPrefix,
    IDateTimePeriod
vb
Public Class DateTimePeriod
    Implements IXmlSerializableElement,
               IDateTimePeriodLimitOwner,
               INameContainer,
               INamedItem,
               ISupportPrefix,
               IDateTimePeriod

The following members return DateTimePeriod objects:

Show 35 links

Remarks

The DateTimePeriod objects are predefined date-time periods in Range Filter and Date Filter items. The RangeFilterDashboardItem.DateTimePeriods and DateFilterDashboardItem.DateTimePeriods properties provide access to the collections of DateTimePeriod objects.

Use the DateTimePeriod static methods to create a predefined period. To create a custom period, instantiate the DateTimePeriod class and perform the following steps:

Note

If you do not specify DateTimePeriod.Start/DateTimePeriod.End, the selection will begin from the start/end of the visible range.

Example

This code snippet creates predefined DateTime periods for the Range Filter dashboard item.

csharp
using DevExpress.DashboardCommon;
// ...
rangeFilter.DateTimePeriods.AddRange(
    DateTimePeriod.CreateLastYear(),
    DateTimePeriod.CreateNextDays("Next 7 Days", 7),
    new DateTimePeriod
    { Name = "Month To Date",
        Start = new FlowDateTimePeriodLimit(DateTimeInterval.Month,0),
        End = new FlowDateTimePeriodLimit(DateTimeInterval.Day,1)
    },
    new DateTimePeriod
    { Name = "Jul-18-2018 - Jan-18-2019",
        Start = new FixedDateTimePeriodLimit(new DateTime(2018, 7, 18)),
        End = new FixedDateTimePeriodLimit(new DateTime(2019, 1, 18)) }
    );
// Specify the period selected when the control is initialized.
rangeFilter.DefaultDateTimePeriodName = "Year To Date";
vb
Imports DevExpress.DashboardCommon
' ...
rangeFilter.DateTimePeriods.AddRange(
    DateTimePeriod.CreateLastYear(),
    DateTimePeriod.CreateNextMonths("Next 3 Months", 3),
    New DateTimePeriod With {
    .Name = "Year To Date",
    .Start = New FlowDateTimePeriodLimit(DateTimeInterval.Year, 0),
    .End = New FlowDateTimePeriodLimit(DateTimeInterval.Day, 1)},
    New DateTimePeriod With {
    .Name = "Jul-18-2018 - Jan-18-2019",
    .Start = New FixedDateTimePeriodLimit(New Date(2018, 7, 18)),
    .End = New FixedDateTimePeriodLimit(New Date(2019, 1, 18))})
' Specify the period selected when the control Is initialized.
rangeFilter.DefaultDateTimePeriodName = "Year To Date"

Inheritance

Object DateTimePeriod

See Also

DateTimePeriod Members

DevExpress.DashboardCommon Namespace