A time interval is composed of a number followed by an optional unit qualifier and aligntment flag. The default units and alignment applied depends on the context the time interval is specified in.

The accepted units of time are:

msec, millisecond, or milliseconds
s, sec, secs, second, or seconds
m, min, mins, minute, or minutes
h, hour, or hours
d, day, or days
w, week, or weeks

The first day of the week is Sunday.

mo, mon, mons, month, or months
q, qtr, qtrs, quarter, or quarters

If the first day of the year is one, then the quarters start on days 1, 91, 182, and 274.

y, year, or years
No suffix

Default units in effect (often seconds).

Example 1. One hour

1h

Example 2. Two weeks

2 week

For milliseconds, seconds, minutes, hours, days and weeks the number can have a fractional component. In this mode the actual interpretation is the largest unit smaller than the specified one that can divide evenly into the specified fraction. For example, specifying 1.5 hours is interpreted as 90 minutes. This becomes important when considering alignment.

A time interval can be thought of as an offset from one time to another that determines the bounds of the interval. This clarification is required to understand the concept of alignment of intervals.

The default alignment depends on the context but it can be explicitly set by adding a suffix to the specification:

a, align, or aligned

Enable alignment.

na, noalign, noaligned, no align, no aligned

Disable alignment.

No suffix

Default alignment (often no alignment).

Example 3. One hour with alignment

1ha

Example 4. Default units aligned

2 align

Alignment is relatively easy to understand in the context of a single unit. In this context the alignment just rounds up or down (depending on the context) to the nearest boundary of the logical unit.

Example 5. Simple alignment

If an interval of one hour aligned is specified and applied forward to 2016-01-01T00:15:00Z then the result is 2016-01-01T02:00:00Z.

If it was applied to 2016-01-01T00:00:00Z then the result is 2016-01-01T01:00:00Z.

This concept extends to even the more complex units of time. For example, month alignment applies to the logical month boundaries, even if the number of days per month is not constant.

Alignment becomes more complicated when it is used with a number that is not exactly one. For the variable length and complex intervals (day, week, month, quarter and year) it behaves the same as their simple case, just rounding to the nearest single interval. For the remaining intervals, it will attempt to divide them into the next logical one to get an even interval. In other words, if the interval specified is an integer divisor of the larger one then the alignment takes effect on the outside interval. For the most part, this means intervals like 15 minutes align as expected to the 15 minute intervals after the hour.

Example 6. Mulitple alignment

If an interval of 15 minutes is specified then the alignment boundaries are every 15 minutes in the hour. So if it was applied forward to 2016-01-01T00:13:00Z the result would be 2016-01-01T00:30:00Z. If instead it was applied to 2016-01-01T00:00:00Z the result would be 2016-01-01T00:15:00Z.

If the interval was instead 16 minutes then it would fall back to 1-minute boundaries because 16 doest not divide evenly into 60. If the 16 minute interval was applied to 2016-01-01T00:13:00Z the result would be 2016-01-01T00:29:00Z.