Splunk Search

Need to filter out latest one year date for the particular field in table

Ashwini_5
Explorer

Hello Experts, 

 

Kindly help to filter out latest one year date for the particular field. 

For ex:  index="abc" sourcetype="xyz" 
|table ID, COMPLETION_DATE, LEARNING_ITEM_ID, LEARNING_ITEM_TITLE, TARGET_DATE

Here I just need to filter out who has completed within last one year in the completion date . Actually, Completion date showing for last five years .. But I just need to filter out only for past year without mentioning any date in query. I am wondering if we can use latest command .. Kindly help  

 

Labels (2)
Tags (1)
0 Karma
1 Solution

richgalloway
SplunkTrust
SplunkTrust

To find dates within the past year, first convert the date into epoch form then compare the result to the current time using relative_time().

index="abc" sourcetype="xyz" 
| eval CD=strptime(COMPLETION_DATE, "<<insert format string here>>")
| where CD >= relative_time(CD, "-1year")
| table ID, COMPLETION_DATE, LEARNING_ITEM_ID, LEARNING_ITEM_TITLE, TARGET_DATE

 

---
If this reply helps you, Karma would be appreciated.

View solution in original post

richgalloway
SplunkTrust
SplunkTrust

To find dates within the past year, first convert the date into epoch form then compare the result to the current time using relative_time().

index="abc" sourcetype="xyz" 
| eval CD=strptime(COMPLETION_DATE, "<<insert format string here>>")
| where CD >= relative_time(CD, "-1year")
| table ID, COMPLETION_DATE, LEARNING_ITEM_ID, LEARNING_ITEM_TITLE, TARGET_DATE

 

---
If this reply helps you, Karma would be appreciated.
Get Updates on the Splunk Community!

Accelerating Observability as Code with the Splunk AI Assistant

We’ve seen in previous posts what Observability as Code (OaC) is and how it’s now essential for managing ...

Integrating Splunk Search API and Quarto to Create Reproducible Investigation ...

 Splunk is More Than Just the Web Console For Digital Forensics and Incident Response (DFIR) practitioners, ...

Congratulations to the 2025-2026 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...