ApplyCalendar function

The ApplyCalendar function applies a new calendar to a time series.

Syntax

ApplyCalendar (ts       TimeSeries, 
              cal_name lvarchar,
              flags    integer default 0) 
returns TimeSeries;
ts
The specified time series from which specific timepoints are projected.
cal_name
The name of the calendar to apply.
flags
Valid values for the flags argument are described in The flags argument values. The default is 0.

Description

If the calendar specified by the argument has an interval smaller than the calendar attached to the original time series, and the original time series is regular, then the resulting time series has a higher frequency and can therefore have more elements than the original time series. For example, applying an hourly calendar with eight valid timepoints per day to a daily time series converts each daily entry in the new time series into eight hourly entries.

Returns

A new time series that uses the named calendar and includes entries from the original time series on active timepoints in the new calendar.

Example

Assuming fourdaycal is a calendar that contains four-day workweeks, the following query returns a time series of a given stock's data for each of the four working days:
select ApplyCalendar(stock_data,'fourdaycal')
   from daily_stocks
   where stock_name = 'HCLTECH';