GetIndex function

The GetIndex function returns the index (offset) of the time series entry associated with the supplied time stamp.

Syntax

GetIndex(ts     TimeSeries, 
        tstamp datetime year to fraction(5)) 
returns integer;
ts
The source time series.
tstamp
The time stamp of the entry.

Description

The data extracted is associated with the time period that the time stamp is in. For example, if you have a time series set to hourly, 8:00 a.m. to 5:00 p.m., the time stamp 3:15 p.m. would return the index associated with 3:00 p.m.

The API equivalent of this function is ts_index().

Returns

The integer offset of the entry for the given time stamp in the time series.

NULL is returned if the time stamp is not a valid day in the calendar, or if it falls before the origin of the time series.

Example

The following example returns the offset for the supplied time stamp:
select stock_name, GetIndex(stock_data,
      '2011-01-05 00:00:00.00000')
 from daily_stocks;

Copyright© 2018 HCL Technologies Limited