Specify time modifiers in your search
When searching or saving a search, you can specify absolute and relative time ranges using the following time modifiers:
An absolute time range uses specific dates and times, for example, from 12 A.M. November 1, 2018 to 12 A.M. November 13, 2018.
A relative time range is dependent on when the search is run. For example, a relative time range of -60m means 60 minutes ago. If the current time is 3 P.M., the search returns events from the last 60 minutes, or 2 P.M. to 3 P.M. today.
The current time is referred to as Now.
Time modifiers and the Time Range Picker
A time range that you specify in the Search bar, or in a saved search, overrides the time range that is selected in the Time Range Picker.
For example, if you specify a time range of
Last 24 hours in the Time Range Picker and in the Search bar you specify
earliest=-30m latest=now, the search only looks at events that have a timestamp within the last 30 minutes.
This applies to any of the options you can select in the Time Range Picker,
However, this does not apply to subsearches.
Time ranges and subsearches
Time ranges selected from the Time Range Picker apply to the main search and to subsearches, unless a time range is specified in the Search bar.
Time ranges that you specify directly in the Search bar apply only to that portion of the search.
- The time ranges specified in the main search do not apply to subsearches.
- Time time ranges specified in a subsearch applies only to that subsearch. The time range does not apply to the main search or any other subsearch.
Specify absolute time ranges
For exact time ranges, the syntax for the time modifiers is
%m/%d/%Y:%H:%M:%S. For example, the following search specifies a time range from 12 A.M. October 19, 2018 to 12 A.M. October 27, 2018.
If you specify only the
earliest time modifier,
latest is set to the current time Now by default. If you specify a
latest time modifier, you must also specify an
Specify relative time ranges
You define the relative time in your search by using a string of characters that indicate the amount of time. The syntax is an integer and a time unit.
1. Begin your string with a minus ( - ) or a plus ( + ) to indicate the offset before or after the time amount.
2. Specify the amount of time by using a number and a time unit. When you specify single time amounts, the number is implied. For example
s is the same as
m is the same as
1m, and so on. The supported time units are listed in the following table.
|Time range||Valid values|
|seconds||s, sec, secs, second, seconds|
|minutes||m, min, minute, minutes|
|hours||h, hr, hrs, hour, hours|
|days||d, day, days|
|weeks||w, week, weeks|
|months||mon, month, months|
|quarters||q, qtr, qtrs, quarter, quarters|
|years||y, yr, yrs, year, years|
When specifying relative time, use
Now to refer to the current time.
Relative time modifiers that snap to a time
With relative time, you can specify a snap to time, which is an offset from the relative time. The snap to time unit rounds down to the nearest or latest time for the time amount that you specify. To do this, separate the time amount from the snap to time unit with an "@" character.
The syntax for the snap to time unit is
When snapping to the nearest or latest time, Splunk software always snaps backwards or rounds down to the latest time that is not after the specified time. For example, the current time is 15:45:00 and the snap to time is
earliest=-h@h. The time modifier snaps to 14:00.
You can also define the relative time modifier using only the snap to time unit. For example, to snap to a specific day of the week, use @w0 for Sunday, @w1 for Monday, and so forth. For Sunday, you can specify either w0 or w7.
If you do not specify a snap to time unit, the search uses seconds as the snap to time unit.
The snap to option becomes very useful in a range of situations. For example, if you want to search for events in the previous month, specify
earliest=-mon@mon latest=@mon. This example begins at the start of the previous month and ends at the start of the current month.
Difference between relative time and relative snap to time
On April 28th, you decide to run a search at 14:05.
- If you specify
earliest=-2d, the search goes back exactly two days, starting at 14:05 on April 26th.
- If you specify
earliest=-2d@d, the search goes back to two days and snaps to the beginning of the day. The search looks for events starting from 00:00 on April 26th.
Special time units
The following abbreviations are reserved for special cases of time units and snap time offsets.
||If you want to search events from the start of UNIX epoch time, use |
||Specify that the search starts or ends at the current time.|
||Specify a snap to the beginning of the most recent quarter: Jan 1, Apr 1, July 1, or Oct 1.|
||Specify "snap to" days of the week; where w0 is Sunday, w1 is Monday, etc. When you snap to a week, |
Examples of relative time modifiers
For these examples, the current time is Wednesday, 05 February 2019, 01:37:05 P.M. Also note that 24h is usually but not always equivalent to 1d because of Daylight Savings Time boundaries.
|Time modifier||Description||Resulting time||Equivalent modifiers|
|now||Now, the current time||Wednesday, 05 February 2019, 01:37:05 P.M.||now|
|-60m||60 minutes ago||Wednesday, 05 February 2019, 12:37:05 P.M.||-60m@s|
|-1h@h||1 hour ago, to the hour||Wednesday, 05 February 2019, 12:00:00 P.M.|
|-1d@d||Yesterday||Tuesday, 04 February 2019, 12:00:00 A.M.|
|-24h||24 hours ago (yesterday)||Tuesday, 04 February 2019, 01:37:05 P.M.||-24h@s|
|-7d@d||7 days ago, 1 week ago today||Wednesday, 28 January 2019, 12:00:00 A.M.|
|-7d@m||7 days ago, snap to minute boundary||Wednesday, 28 January 2019, 01:37:00 P.M.|
|@w0||Beginning of the current week||Sunday, 02 February 2019, 12:00:00 A.M.|
|+1d@d||Tomorrow||Thursday, 06 February 2019, 12:00:00 A.M.|
|+24h||24 hours from now, tomorrow||Thursday, 06 February 2019, 01:37:05 P.M.||+24h@s|
Examples of chained relative time offsets
You can also specify offsets from the snap-to-time or "chain" together the time modifiers for more specific relative time definitions.
|Time modifier||Description||Resulting time|
|@d-2h||Snap to the beginning of today (12 A.M.) and subtract 2 hours from that time.||10 P.M. last night.|
|-mon@mon+7d||One month ago, snapped to the first of the month at midnight, and add 7 days.||The 8th of last month at 12 A.M.|
Examples of searches with relative time modifiers
Search from the beginning of the week to the time of your search
This example searches for Web access errors from the beginning of the week to the time that you run your search. Though not specified,
latest=now is assumed with this search
eventtype=webaccess error earliest=@w0
This search returns matching events starting from 12:00 A.M. of the Sunday of the current week to the current time. Of course, this means that if you run this search on Monday at noon, you will only see events for 36 hours of data.
Search the current business week
This example searches for Web access errors from the current business week, where
w1 is Monday and
w6 is Friday.
eventtype=webaccess error earliest=@w1 latest=+7d@w6
This search returns matching events starting from 12:00 A.M. of the Monday of the current week and ending at 11:59 P.M. of the Friday of the current week.
If you run this search on Monday at noon, you will only see events for 12 hours of data. Whereas, if you run this search on Friday, you will see events from the beginning of the week to the current time on Friday. The timeline however, will display for the full business week.
Search the last full business week
This example searches Web access errors from the last full business week.
eventtype=webaccess error earliest=-7d@w1 latest=@w6
This search returns matching events starting from 12:00 A.M. of last Monday and ending at 11:59 P.M. of last Friday.
Search the last 24 hours but omit 1 hour
This example searches an index for the last 24 hours but omits any events returned from Midnight to 1:00 A.M., when downtime returns false log entries.
index=myindex ((earliest=-24h latest<@d) OR (earliest>=@d+1h))
This search specifies two time ranges:
- 24 hours before the search is run, up to midnight
- The beginning of the day that the search is run, starting at 1 hour after midnight or 1:00 A.M.
Select time ranges to apply to your search
Specify time ranges for real-time searches
This documentation applies to the following versions of Splunk® Enterprise: 7.1.0, 7.1.1, 7.1.2, 7.1.3, 7.1.4, 7.1.5, 7.1.6, 7.1.7, 7.1.8, 7.1.9, 7.1.10, 7.2.0, 7.2.1, 7.2.2, 7.2.3, 7.2.4, 7.2.5, 7.2.6, 7.2.7, 7.2.8, 7.2.9, 7.3.0, 7.3.1, 7.3.2, 7.3.3, 7.3.4, 8.0.0, 8.0.1, 8.0.2