GetElem function

The GetElem function extracts the element for the given time stamp.

Syntax

GetElem(ts     TimeSeries, 
       tstamp datetime year to fraction(5),
       flags  integer default 0) 
returns row;
ts
The source time series.
tstamp
The time stamp of the entry.
flags
Valid values for the flags argument are described in The flags argument values. The default is 0.

Description

If the time stamp is for a time that is not part of the calendar, or if it falls before the origin of the given time series, NULL is returned. In some cases, GetLastValid, GetNextValid, or GetPreviousValid might be more appropriate.

For a regular time series, the data extracted is associated with the time period containing the time stamp. For example, if the time series is set to hourly, 8:00 a.m. to 5:00 p.m., the time stamp 3:15 p.m. would return 3:00 p.m. and the data associated with that time.

The API equivalent of this function is ts_elem().

Returns

A row type containing the time stamp and the data from the time series at that time stamp. The type of the row is the same as the time series subtype.

Example

The following query retrieves the stock data of two stocks for a particular day:
select GetElem(stock_data,'2011-01-04 00:00:00.00000')
   from daily_stocks
   where stock_name = 'HCLTECH' or stock_name = 'HWP';