Specify Custom Dates in a Report
The following procedure shows how to specify a custom date range for a report request. The procedure is the same for the BudgetSummaryReportRequest data object, but there are some important differences that are discussed later in this topic.
Create a Custom Date Range
Create an instance of the ReportTime object. Assign the ReportTime object to the Time element of the report request object.
Create a Date object that specifies the start date of the custom date range. Assign the Date object to the ReportTime.CustomDateRangeStart element.
Create another Date object that specifies the end date of the custom date range. Assign the Date object to the ReportTime.CustomDateRangeEnd element.
If you specify a custom date range, you must not set the ReportTime.PredefinedTime element.
The Aggregation element of the report request object determines how the data for the specified time period is aggregated.
The following code example shows how to initialize a report request object to request a custom date range.
// 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;
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.