The PERIOD function generates a timestamp value range, computed relative to the current time. It is a shortcut for commonly-used range clauses that occur close to (or relative to) the current date/time. A timestamp field can be compared to a
PERIOD function to see if its value falls within the corresponding range. A timestamp range clause using the
PERIOD function uses the following form:
field = PERIOD([<timezone>]).<range>
With no parameter, the PERIOD function computes a timestamp range relative to a snapshot of the current time in UTC. If a <timezone> parameter is provided, the UTC time is adjusted up or down to the specified time zone. The <timezone> can be an abbreviation (
PST) or a name (
America/Los_Angeles). The allowable values for a <timezone> abbreviation or name are those recognized by the Java function
java.util.TimeZone.getAvailableIDs().
THIS mnemonics compute a range
around the current time, that is a range that includes the current time. The recognized
THIS mnemonics are:
Note that TODAY is used as the mnemonic for “this day”.
THIS mnemonics use no additional parameters. They define a timeframe (minute, hour, day, week, month, or year) that includes the current time. The timeframe is inclusive of the timeframe start but exclusive of the timeframe end. For example, if the current time is
2013-12-17 12:40:13, the function
PERIOD.THISHOUR defines the range:
["
2013-12-17 12:00:00"
TO "
2013-12-17 13:00:00"
}
LAST mnemonics compute a range that
ends at the current time. That is, they choose a timeframe that leads up to “now”, going back an exact number of units. The recognized
LAST mnemonics are:
By default, the LAST mnemonics reach back one unit: 1 minute, 1 hour, etc. Optionally, they allow an integral parameter that extends the timeframe back a whole number of units. For example,
LASTMINUTE(2) means “within the last 2 minutes”,
LASTMONTH(3) means “within the last 3 months”, etc.
LAST periods are inclusive at both ends of the range. For example, if the current time is
2013-12-17 12:40:13, the function
PERIOD.LASTHOUR defines the range:
["2013-12-17 11:40:13"
TO "
2013-12-17 12:40:13"
]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
["2013-11-27 01:24:35" TO "2013-12-04 01:24:35"]
|
|
|
|
|
|
["2013-11-04 01:24:35" TO "2013-12-04 01:24:35"]
|
|
|
["2013-01-01 00:00:00" TO "201 4-01-01 00:00:00"}
|
|
|
["2012-12-04 01:24:35" TO "2013-12-04 01:24:35"]
|
|