AndOp function

The AndOp function returns the intersection of two calendar patterns.

Syntax

AndOp (cal_patt1 CalendarPattern, 
       cal_patt2 CalendarPattern) 
returns CalendarPattern;
cal_patt1
The first calendar pattern.
cal_patt2
The second calendar pattern.

Description

This function returns a calendar pattern that has every interval on that was on in both calendar patterns; the rest of the intervals are off. If the specified patterns do not have the same interval unit, the pattern with the larger interval unit is expanded to match the other.

Returns

A calendar pattern that is the result of two others that are combined by the AND operator.

Example

The first AndOp statement returns the intersection of two daily calendar patterns, and the second AndOp statement returns the intersection of one hourly and one daily calendar pattern:
select * from CalendarPatterns
                where cp_name = 'workweek_day';

cp_name         workweek_day
cp_pattern         {1 off,5 on,1 off},day

select * from CalendarPatterns
                where cp_name = 'fourday_day';

cp_name         fourday_day
cp_pattern         {1 off,4 on,2 off},day

select * from CalendarPatterns
                where cp_name = 'workweek_hour';

cp_name         workweek_hour
cp_pattern         {32 off,9 on,15 off,9 on,15 off,9 on,15 off, 9
         on,15 off,9 on,31 off},hour

select AndOp(p1.cp_pattern, p2.cp_pattern)
                from CalendarPatterns p1, CalendarPatterns p2
              where p1.cp_name = 'workweek_day'
              and p2.cp_name = 'fourday_day';

(expression) {1 off,4 on,2 off},day

select AndOp(p1.cp_pattern, p2.cp_pattern)
                from CalendarPatterns p1, CalendarPatterns p2
              where p1.cp_name = 'workweek_hour'
              and p2.cp_name = 'fourday_day';

(expression) {32 off,9 on,15 off,9 on,15 off,9 on,15 off,9
          on,55 off},hour