GetPeriodSize(StartDate: DateTime; EndDate: DateTime; Level: DimCalendarLevel): Integer;
StartDate. Date and time of the time span start.
EndDate. Date and time of the time span end.
Level. Period size.
The ObtainPeriodSize method returns the number of periods in selected time span.
Executing the example requires that the repository contains a modeling container with the CONT_MODEL identifier. This modeling container must include a problem with the OBJ_PROBLEM identifier.
Sub UserProc;
Var
MB: IMetabase;
MObj: IMetabaseObject;
Problem: IMsProblem;
Details: IMsForecastingProblem;
Period: IMsModelPeriod;
stDt, endDt: DateTime;
count: Integer;
Begin
MB := MetabaseClass.Active;
MObj := MB.ItemByIdNamespace("OBJ_PROBLEM", MB.ItemById("CONT_MODEL").Key).Bind;
Problem := MObj As IMsProblem;
Details := Problem.Details As IMsForecastingProblem;
Period := Details.Period;
stDt := Period.ForecastStartDate;
endDt := Period.ForecastEndDate;
count := Period.GetPeriodSize(stDt, endDt, DimCalendarLevel.Year);
Debug.WriteLine("Number of years in problem forecasting period: " + count.ToString);
End Sub UserProc;
After executing the example the number of years in the problem forecasting period is displayed in the console window.
See also: