Splunk Search

Trying to limit results by date

declan294
New Member

I am trying to filter results based on a search term (seen below) for only items that match a date from the time searched until the end of the year.

Trying to only receive results for accountExpires from date of search through 12/31/currentyear

Any help is appreciated

index=ad accountExpires=>{CurrentDate} OU="Contractor" accountExpires NOT "Never Expires" | dedup sAMAccountName | table sAMAccountName,accountExpires

Tags (1)
0 Karma

woodcock
Esteemed Legend

Like this:

index=ad OU="Contractor" accountExpires NOT "Never Expires" 
| dedup sAMAccountName
| eval accountExpires=strptime(accountExpires, "<<FormatOfDateInFieldaccountExpires>>")
| fieldformat accountExpires=strftime(accountExpires, "<<FormatOfDateInFieldaccountExpires>>")
| addinfo
| where accountExpires>=info_min_time AND accountExpires<=relative_time(now(), "@y")
| table sAMAccountName accountExpires
0 Karma

somesoni2
Revered Legend

May be like this

index=ad accountExpires>=[| gentimes start=-1 | eval query=strftime(now(),"<<FormatOfDateInFieldaccountExpires>>" | table search]  accountExpires<=[| gentimes start=-1 | eval query=strftime(relative_time(now(),"@y+1y"),"<<FormatOfDateInFieldaccountExpires>>" | table search] OU="Contractor" NOT "Never Expires" | dedup sAMAccountName | table sAMAccountName,accountExpires
0 Karma
Get Updates on the Splunk Community!

More Ways To Control Your Costs With Archived Metrics | Register for Tech Talk

Tuesday, May 14, 2024  |  11AM PT / 2PM ET Register to Attend Join us for this Tech Talk and learn how to ...

.conf24 | Personalize your .conf experience with Learning Paths!

Personalize your .conf24 Experience Learning paths allow you to level up your skill sets and dive deeper ...

Threat Hunting Unlocked: How to Uplevel Your Threat Hunting With the PEAK Framework ...

WATCH NOWAs AI starts tackling low level alerts, it's more critical than ever to uplevel your threat hunting ...