IMsTimeMatrix.DateToIndex

Fore Syntax

DateToIndex(Value: DateTime): Integer;

Fore.NET Syntax

DateToIndex(Value: System.DateTime): integer;

Parameters

Value. Calendar series point.

Description

The DateToIndex method transforms date to index.

Comments

To transform index to date, use the IMsTimeMatrix.IndexToDate method.

Fore Example

This example describes custom method.

To execute the example, add links to the MS, MathFin system assemblies.

Public Function Max(Matrix: IMsTimeMatrix): Variant;
Var
    Serie : ITimeSeries;
    index, i : integer;
    arr : Array Of double;
Begin
    Serie := New TimeSeries.Create;
    index := Matrix.CurrentIndex;
    If Matrix.DateToIndex(Matrix.ForecastStartDate) <> index Then
        For i := 0 To Matrix.PointCount - 1 Do
            arr := Matrix.Column(i) As Array Of double;
            Serie.Item(i) := Math.Max(arr);
        End For;
    End If
    Return Serie;
End Function Max;

The method finds maximum value in matrix series points if the value obtained on transformation of date into index does not match the current calculation index.

Fore.NET Example

The requirements and result of the Fore.NET example execution match with those in the Fore example.

Imports Prognoz.Platform.Interop.Ms;
Imports Prognoz.Platform.Interop.MathFin;

Public Function Max1(Matrix: IMsTimeMatrix): object;
Var
    Serie : ITimeSeries;
    index, i : integer;
    arr : Array Of double;
    Math: MathClass = New MathClass();
Begin
    Serie := New TimeSeries.Create();
    index := Matrix.CurrentIndex;
    If Matrix.DateToIndex(Matrix.ForecastStartDate) <> index Then
        For i := 0 To Matrix.PointCount - 1 Do
            arr := Matrix.Column(i) As Array Of double;
            Serie.Item[i] := Math.Max(arr);
        End For;
    End If;
    Return Serie;
End Function Max1;

See also:

IMsTimeMatrix