AndOp function
The AndOp function returns the intersection of the two calendars.
Syntax
AndOp (cal1 Calendar,
cal2 Calendar)
returns Calendar;
- cal1
- The first calendar.
- cal2
- The second calendar.
Description
This function returns a calendar that has every interval on that was on in both calendars; the rest of the intervals are off. The resultant calendar takes the later of the two start dates and the later of the two pattern start dates.
If the two calendars have different size interval units, the resultant calendar has the smaller of the two intervals.
Returns
A calendar that is the result of two other calendars that are combined with the AND operator.
Example
The following AndOp statement
returns the intersection 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 AndOp(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 results:
(expression)
startdate(2011-04-01 00:00:00), pattstart(2011-04-03
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)