Specify custom dates for a report by using one of the following techniques:
-
Specify a consecutive date range.
-
Specify a set of dates.
Both techniques are used with the following report request objects:
These techniques are basically the same for the BudgetSummaryReportRequest class, but there are some important differences. They are discussed later in this topic.
Generate a Report for a Consecutive Date Range
-
Create an instance of the ReportTime object. Set the
Time element of the report request object equal to this ReportTime object.
-
Create a
Date structure, and then set it equal to the beginning date for the report. Set the ReportTime.CustomDateRangeStart element to this Date structure.
-
Create another
Date structure, and then set it equal to the ending date for the report. Set the ReportTime.CustomDateRangeEnd element to this Date structure.
Note: |
|---|
Do not use the ReportTime.PredefinedTime or ReportTime.CustomDates elements.
|
-
Set the
Aggregation element of the report request object to the desired time interval from the ReportAggregation values. The aggregation type specifies the time unit that the reports are aggregated by.
The following code example shows how to initialize a report request object to request a report for a range of dates.
// Create an instance of the ReportTime class to hold the report date
// information.
request.Time = new ReportTime();
// Set the start date for the report to one month before today.
DateTime startDate = DateTime.Today.AddMonths(-1);
request.Time.CustomDateRangeStart = new Date();
request.Time.CustomDateRangeStart.Day = startDate.Day;
request.Time.CustomDateRangeStart.Month = startDate.Month;
request.Time.CustomDateRangeStart.Year = startDate.Year;
// Set the end date to today.
DateTime endDate = DateTime.Today;
request.Time.CustomDateRangeEnd = new Date();
request.Time.CustomDateRangeEnd.Day = endDate.Day;
request.Time.CustomDateRangeEnd.Month = endDate.Month;
request.Time.CustomDateRangeEnd.Year = endDate.Year;
Generate a Report for a Specific Set of Dates
-
Create an instance of the ReportTime object. Set the
Time property of the report request object equal to this ReportTime object.
-
Allocate an array of
Date structures that has the same number of elements as the number of dates for the report. Assign this array to the ReportTime.CustomDates element.
-
Assign each element in the
ReportTime.CustomDates array to a Date structure that contains one of the desired report dates.
Note: |
|---|
Do not use the ReportTime.PredefinedTime, ReportTime.CustomDateRangeStart, or ReportTime.CustomDateRangeEnd elements.
|
-
Set the
Aggregation element of the report request object to the desired time interval from the ReportAggregation enumeration. The aggregation type specifies the time unit by which the reports are aggregated.
The following code example shows how to initialize a report request object to request a report for a specific set of dates.
// Create an instance of the ReportTime class to hold the report date
// information.
request.Time = new ReportTime();
// Allocate an array of DateTime structures to hold the report dates.
request.Time.CustomDates = new Date[2];
// Create a date for 12/28/2005.
DateTime tempDate = new DateTime(2005, 12, 28);
request.Time.CustomDates[0] = new Date();
request.Time.CustomDates[0].Day = tempDate.Day;
request.Time.CustomDates[0].Month = tempDate.Month;
request.Time.CustomDates[0].Year = tempDate.Year;
// Create a date for one month before today.
tempDate = DateTime.Today.AddMonths(-1);
request.Time.CustomDates[1] = new Date();
request.Time.CustomDates[1].Day = tempDate.Day;
request.Time.CustomDates[1].Month = tempDate.Month;
request.Time.CustomDates[1].Year = tempDate.Year;
Budget Summary Reports
When you use the BudgetSummaryReportRequest object, the process for using customized dates is basically the same. The difference is that budget summary reports are always aggregated at the day level. To support this, the BudgetSummaryReportRequest object does not contain an Aggregation element. Also, the BudgetSummaryReportRequest.Time element is of the BudgetSummaryReportTime type. The BudgetSummaryReportTime.PredefinedTime element is of the BudgetSummaryReportTimePeriod type, which contains a reduced set of predefined report dates.
Concepts
Request and Download a Report