Splunk Search

Display rows not older than 1 day based in a date column

rsokolova
Path Finder

Thanks in advance.

We are trying to display the rows where the column is not older than 1 day and this has to be done comparing columns.

Example today is 11/9/2017 and we are trying to just to display the data from yesterday and today based in the Return_Date column.

alt text

This is only data that we would need to see.
alt text

0 Karma
1 Solution

LCM_BRogerson
Path Finder

Hi @rsokolova

To get the current date and time in epoch format you can use:
| eval timenow=now()
To get a date/time relative to now you can use:
| eval yesterday=relative_time(now(), "-1d@d")
In order to compare dates they need to be in the same format, so convert the time to the same format as your return date field:
| eval yesterday=strftime(relative_time(now(), "-1d@d"), "%d-%b-%y)
Before your table, you can add a where clause to remove the data you don't want.
| where Return_Date>=yesterday

Hope this helps.

View solution in original post

LCM_BRogerson
Path Finder

Hi @rsokolova

To get the current date and time in epoch format you can use:
| eval timenow=now()
To get a date/time relative to now you can use:
| eval yesterday=relative_time(now(), "-1d@d")
In order to compare dates they need to be in the same format, so convert the time to the same format as your return date field:
| eval yesterday=strftime(relative_time(now(), "-1d@d"), "%d-%b-%y)
Before your table, you can add a where clause to remove the data you don't want.
| where Return_Date>=yesterday

Hope this helps.

Get Updates on the Splunk Community!

Splunk Observability for AI

Don’t miss out on an exciting Tech Talk on Splunk Observability for AI!Discover how Splunk’s agentic AI ...

Splunk Enterprise Security 8.x: The Essential Upgrade for Threat Detection, ...

Watch On Demand the Tech Talk, and empower your SOC to reach new heights! Duration: 1 hour  Prepare to ...

Splunk Observability as Code: From Zero to Dashboard

For the details on what Self-Service Observability and Observability as Code is, we have some awesome content ...