Time Window String
Time Window String Representation
Time Window String Representation
To specify time ranges at ease, airframe-metrics uses the following string representation of time windows, such as -1d, -30m, +7d, etc. Values with (or without)- sign means the last time range, and values with + sign means the next time range from the context time.
DURATION := (+ | -)?(INTEGER)(UNIT) UNIT := s | m | h | d | w | M | q | y
OFFSET := DURATION | DATE_TIME RANGE := (OFFSET) (/ (OFFSET))* DATE_TIME := yyyy-MM-dd( HH:mm:ss(.ZZZ|' ' z)?)?
Examples
Here are several examples of relative time window strings when the current time is 2016-06-26 01:23:45-0700: Duration Definition start end (exclusive) 1h this hour 2016-06-26 01:00:00-0700 2016-06-26 02:00:00-0700 1d today 2016-06-26 00:00:00-0700 2016-06-27 00:00:00-0700 1M this month 2016-06-01 00:00:00-0700 2016-07-01 00:00:00-0700 -1h last hour 2016-06-26 00:00:00-0700 2016-06-26 01:00:00-0700 -1h/0h last hour 2016-06-26 00:00:00-0700 2016-06-26 01:00:00-0700 -1h/0m last hour until last minute 2016-06-26 00:00:00-0700 2016-06-26 01:23:00-0700 -1h/0s last hour until last second 2016-06-26 00:00:00-0700 2016-06-26 01:23:45-0700 -1h/now last hour to now 2016-06-26 00:00:00-0700 2016-06-26 01:23:45-0700 -60m/2017-01-23 01:23:45 last 60 min from an offset 2017-01-23 00:23:00-0700 2017-01-23 01:23:00-0700 -1d last day 2016-06-25 00:00:00-0700 2016-06-26 00:00:00-0700 -7d last 7 days 2016-06-19 00:00:00-0700 2016-06-26 00:00:00-0700 -7d/now last 7 days to now 2016-06-10 00:00:00-0700 2016-06-26 01:23:45-0700 -3d/2017-04-07 last 3 days from an offset 2017-04-04 00:00:00-0700 2017-04-07 00:00:00-0700 +7d next 7 days (including today) 2016-06-26 00:00:00-0700 2016-07-03 00:00:00-0700 +7d/now next 7 days from now 2016-06-26 01:23:45-0700 2016-07-03 00:00:00-0700 -1w last week 2016-06-13 00:00:00-0700 2016-06-20 00:00:00-0700 -1M last month 2016-05-01 00:00:00-0700 2016-06-01 00:00:00-0700 -1q last quarter 2016-01-01 00:00:00-0700 2016-04-01 00:00:00-0700 -1y last year 2015-01-01 00:00:00-0700 2016-01-01 00:00:00-0700 -1h/2017-01-23 01:00:00 last hour from offset (hour) 2017-01-23 00:00:00-0700 2017-01-23 01:00:00-0700 -1h/2017-01-23 01:23:45 last hour from offset (hour) 2017-01-23 00:00:00-0700 2017-01-23 01:00:00-0700 -1M/2017-01-23 01:23:45 last month from offset (hour) 2016-12-01 00:00:00-0700 2017-01-01 00:00:00-0700 2017-01-23/2017-01-25 exact date range 2017-01-23 00:00:00-0700 2017-01-25 00:00:00-0700 2017-01-23 01:23:45/2017-01-25 01:23:45 exact time range 2017-01-23 01:23:45-0700 2017-01-25 1:23:45-0700 2016-01-01/0d from time to the offset 2016-01-01 00:00:00-0700 2016-06-26 00:00:00-0700 0M/2017-01-23) no unit truncation (backward) 2017-01-01 00:00:00-0700 2017-01-23 00:00:00-0700 +1M/2017-01-23 01:23:45) no unit truncation (forward) 2017-01-23 01:23:45-0700 2017-02-01 00:00:00-0700