GetPreviousValid function
The GetPreviousValid function returns the last element before the given time stamp.
Syntax
GetPreviousValid(ts TimeSeries,
tstamp datetime year to fraction(5),
flags integer default 0)
returns row;
- ts
- The source time series.
- tstamp
- The time stamp of interest.
- flags
- Valid values for the flags argument are described in The flags argument values. The default is
0
.
Description
The equivalent API function is ts_previous_valid().
Returns
A row containing the last element before the given time stamp. The type of the row is the same as the time series subtype.
If the time stamp is less than or equal
to the time series origin, NULL
is returned.
Example
The following query gets the first
element that precedes time stamp 2011-01-05 in a regular time series:
select GetPreviousValid(stock_data,
'2011-01-05 00:00:00.00000')
from daily_stocks
where stock_name = 'IBM';
The following query
gets the first element that precedes time stamp 2011-01-05 in an irregular
time series:
select GetPreviousValid(activity_data,
'2011-01-05 00:00:00.00000')
from activity_stocks
where stock_id = 600;