Calendar

Every time series is associated with a calendar. A calendar defines a set of valid times for elements in a time series.

Each calendar has a calendar pattern of time periods during which data is allowed or prohibited. Data can be recorded during on periods but cannot be recorded during off periods. The calendar pattern is based on a time interval; for example, second, minute, hour, day, or month. A start date specifies when the pattern starts.

Suppose you want to collect data once a day Monday through Friday. The following table illustrates when data collection is allowed, or on, and prohibited, or off. The pattern has an interval of a day, a start date on a Sunday, and specifies one day off, five days on, and one day off:

{1 off, 5 on, 1 off}, day
Table 1. When data collection is on or off
Sunday Monday Tuesday Wednesday Thursday Friday Saturday
OFF: data is prohibited ON: data is allowed ON: data is allowed ON: data is allowed ON: data is allowed ON: data is allowed OFF: data is prohibited
OFF: data is prohibited ON: data is allowed ON: data is allowed ON: data is allowed ON: data is allowed ON: data is allowed OFF: data is prohibited

For regular time series, an interval represents the range of time in which one element is allowed. You cannot enter more than one element into an interval. The value of an element persists for the length of one interval. If you query for a value in an off period, you receive an error. Intervals that are missing data are null. You can query for null elements to find which elements are missing.

For irregular time series, the interval is only relevant for designating off periods when data is not allowed. The interval size for valid periods does not affect the number of elements that you can insert into a specific time range. For example, although the smallest interval size is a second, you can enter subsecond frequency elements into an irregular time series. The value of an element persists until the next element. If you query for a value in an off period, you receive the value of the last element. Irregular time series have no null elements.

You can use a predefined calendar or define your own calendar. The seven predefined calendars each have a different interval duration that ranges from one minute to one month. All the predefined calendars start at the beginning of 2011, but you can alter the start date. You create a calendar by inserting a row into the CalendarTable table in the format of a Calendar data type. You can include the calendar pattern in the calendar definition, or create a separate calendar pattern by inserting a row into the CalendarPatterns table in the format of a CalendarPattern data type.

You can aggregate information by selecting data and changing the calendar for the results of the query. Use the AggregateBy function to aggregate data. For example, if you collect electricity usage information every 15 minutes, but you want to know the total usage per customer per day, you can specify a daily calendar in the AggregateBy function to aggregate the data.

You can use calendar and calendar pattern routines to manipulate calendars and calendar patterns. For example, you can create the intersection of calendars or calendar patterns.