AlignedDate(Value: DateTime;
[Forward: Boolean = true;]
[ThrowException: Boolean = true]): DateTime;
Value. Checked date.
Forward. Calendar offset direction.
ThrowException. Indicates whether to throw exception if the verifiable date is out of limits of series dates.
The AlignedDate property returns nearest valid date.
Available values of the ThrowException parameter:
True. Default value. The exception is thrown.
False. The method returns the nearest date to start or end of the series.
If the verifiable date is a holiday, the method returns the nearest valid date depending on value of the Forward parameter:
Forward = True. Default value. The nearest valid date forward the calendar.
Forward = False. The nearest valid date backward the calendar.
If the checked date is a working day, the method returns the checked date without changes.
This example describes custom method.
To execute the example, add links to the Ms system assemblies.
Public Function UserAlignedDate(param: IMsTimeMatrix): Variant;
Var
m : IMsTimeMatrix;
i : Integer;
IndDate: DateTime;
Begin
m := New MsTimeMatrix.Create;
For i := m.StartIndex To m.EndIndex Do
IndDate := m.IndexToDate(i);
If m.AlignedDate(IndDate) = IndDate Then
Debug.WriteLine(m.Item(i));
End If;
End For;
Return m;
End Function UserAlignedDate;
After executing the example the console window displays values of matrix series points if the nearest valid date matches the date obtained after transforming index to date.
See also: