Collapse function

The Collapse function collapses the specified calendar pattern into destination units, which must have a larger interval unit than the interval unit of the specified calendar pattern.

Syntax

Collapse (cal_patt  CalendarPattern, 
          interval   lvarchar) 
returns CalendarPattern; 
cal_patt
The calendar pattern to be collapsed.
interval
The destination time interval: minute, hour, day, week, month, or year.

Description

If any part of a destination unit is on, the whole unit is considered on.

Returns

The collapsed calendar pattern.

Example

The following statements convert an hourly calendar pattern into a daily calendar pattern:
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 Collapse(cp_pattern, 'day')
from CalendarPatterns
            where cp_name = 'workweek_hour';

(expression) {1 off,5 on,1 off},day