Dashboards & Visualizations

## How to get data by comparing with a date field and current date?

Path Finder

We have different licenses expires by different dates .The current sourcetype data comprises of both future expiry and past expiry too.

we don’t want license that are expired meaning anything that is before the current day.

"Expire valid To" field will have this date .

Please let me know how to achieve this in SPL .

Labels (1)
• ### timechart

Tags (1)
1 Solution
SplunkTrust

Here's a simple example that generates 20 dates within one year before or after today and makes that date YYYY-MM-DD.

The where clause simply checks that date is >= today

``````| makeresults count=20
``` Make up a random sample of expiry dates within 1 uyear before and after today ```
| eval r=365
| eval range=random() % (r * 2 * 86400)
| eval "Expire valid To"=strftime(now() + (r * 86400) - range, "%F")
``` Now simply test whether the expiry date is today or later ```
| where strptime('Expire valid To', "%F") >= relative_time(now(), "@d")``````

The last line is what you will need. Depending on your date format, change the strptime format variable (currently %F is YYYY-MM-DD).

Path Finder

It works bowesmana .Thank you .

SplunkTrust

Here's a simple example that generates 20 dates within one year before or after today and makes that date YYYY-MM-DD.

The where clause simply checks that date is >= today

``````| makeresults count=20
``` Make up a random sample of expiry dates within 1 uyear before and after today ```
| eval r=365
| eval range=random() % (r * 2 * 86400)
| eval "Expire valid To"=strftime(now() + (r * 86400) - range, "%F")
``` Now simply test whether the expiry date is today or later ```
| where strptime('Expire valid To', "%F") >= relative_time(now(), "@d")``````

The last line is what you will need. Depending on your date format, change the strptime format variable (currently %F is YYYY-MM-DD).

Get Updates on the Splunk Community!

#### Build Scalable Security While Moving to Cloud - Guide From Clayton Homes

Clayton Homes faced the increased challenge of strengthening their security posture as they went through ...

#### Mission Control | Explore the latest release of Splunk Mission Control (2.3)

We’re happy to announce the release of Mission Control 2.3 which includes several new and exciting features ...

#### Cloud Platform | Migrating your Splunk Cloud deployment to Python 3.7

Python 2.7, the last release of Python 2, reached End of Life back on January 1, 2020. As part of our larger ...