GetNextValid function

The GetNextValid function returns the nearest entry after a given time stamp.

Syntax

GetNextValid(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

For regular time series, GetNextValid returns the element at the calendar's earliest valid timepoint following the given time stamp. For irregular time series, it returns the earliest element following the given time stamp.

The equivalent API function is ts_next_valid().

Returns

A row type containing the nearest element after the given time stamp. The type of the row is the same as the time series subtype.

NULL is returned if the time stamp is later than that of the last time stamp in the time series.

Example

The following example gets the first element that follows time stamp 2011-01-03 in a regular time series:
select GetNextValid(stock_data,'2011-01-03 00:00:00.00000')
   from daily_stocks
   where stock_name = 'IBM';
The following example gets the first element that follows time stamp 2011-01-03 in an irregular time series:
select GetNextValid(activity_data, 
   '2011-01-03 00:00:00.00000')
   from activity_stocks
   where stock_id = 600;