ClipCount function
The ClipCount function is a variation of Clip in which the first integer argument is interpreted as a count of entries to clip. If the count is positive, ClipCount begins with the first element at or after the time stamp and clips the next count entries. If the count is negative, ClipCount begins with the first element at or before the time stamp and clips the previous count entries.
Syntax
ClipCount(ts TimeSeries,
begin_stamp datetime year to fraction(5),
num_stamps integer,
flag integer default 0)
returns TimeSeries;
- ts
- The time series to clip.
- begin_stamp
- The begin point of the range. Can be
NULL
. - num_stamps
- The number of elements to be included in the resultant time series.
- flag (optional)
- The configuration of the resulting time series. For details, see the Clip function.
Description
Begin points before the time series origin are permitted. Negative counts with such time stamps result in time series with no elements. Begin points before the calendar origin are not permitted.
If there is no entry in the calendar
exactly at the requested time stamp, ClipCount uses
the calendar's first valid time stamp that immediately follows the
given time stamp as the begin point of the range. If the begin point
is NULL
, the origin of the time series is used.
The timestamp of the first record in a resulting irregular time series is later than or equal to the begin point. However, the value of a record in an irregular time series persists until the next record. Therefore, by default, the first record in the resulting time series can have a value that corresponds to an earlier timestamp than the begin point. You can specify that the first record in the resulting time series is the first record whose timestamp is equal to or after the begin point by including the flag argument value of 16.
You can specify that the resulting time series is irregular by including the flag argument value of 8.
You can choose whether the origin of the resulting time series can be earlier than the origin of the input time series by setting the flag argument. By default, the origin of the resulting time series cannot be earlier than the origin of the input time series. You can also control how hidden elements are handled with the flag argument. By default, hidden elements from the input time series are not included in the resulting time series. You can include hidden element in the resulting time series and specify whether those elements remain hidden or are revealed in the resulting time series.
Returns
A new time series containing only data from the requested range. The new series has the same calendar as the original, but it can have a different origin and number of entries.
Example
select ClipCount(activity_data,
'2011-01-01 09:30:00.00000', 30)
from activity_stocks
where stock_id = 600;
select ClipCount(activity_data,
'2011-08-22 00:00:00.00000', -60)
from activity_stocks
where stock_id = 600;