OrOp function

The OrOp function returns the union of the two calendars.

Syntax

OrOp (cal1 Calendar, 
      cal2 Calendar) 
returns Calendar;
cal1
The first calendar to be combined.
cal2
The second calendar to be combined.

Description

This function returns a calendar that has every interval on that was on in either calendar; the rest of the intervals are off. The resultant calendar takes the earlier of the two start dates and the two pattern start dates.

If the two calendars have different sizes of interval units, the resultant calendar has the smaller of the two intervals.

Returns

A calendar that is the result of two others that are combined with the OR operator.

Example

The following OrOp function returns the union of an hourly calendar with a daily calendar that has a different start date:
select c_calendar from CalendarTable
            where c_name = 'hourcal';

c_calendar      startdate(2011-01-01 00:00:00), pattstart(2011-
          01-02 00:00:00), 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 c_calendar from CalendarTable
            where c_name = 'daycal';

c_calendar   startdate(2011-04-01 00:00:00), pattstart(2011-
          04-03 00:00:00), pattern({1 off,5 on,1 off},day) 

select OrOp(c1.c_calendar, c2.c_calendar)
            from CalendarTable c1, CalendarTable c2
            where c1.c_name = 'daycal' and c2.c_name = 'hourcal';

The query returns the following result:

(expression)

startdate(2011-01-01 00:00:00), pattstart(2011-01-02
00:00:00), pattern({24 off,120 on,24 off},hour)