Getting Data In

How can I only show rows from next 6 months based on the datestamp?

rkassabov
Path Finder

I am trying to only show records that have "md_createdAt" fields that occur in the next 6 months, looking forward from that day's date. How would I only show these records?

|`init("xxx")`
| eval month=strftime(strptime(md_createdAt,"%Y-%m-%d %H:%M:%S.%6N"),"%b")
| table info_subType md_createdAt month
| chart count(info_subType) over month by md_createdAt
Tags (2)
0 Karma
1 Solution

somesoni2
SplunkTrust
SplunkTrust

Just add following before |eval month.. line:

| where strptime(md_createdAt,"%Y-%m-%d %H:%M:%S.%6N")>now() AND strptime(md_createdAt,"%Y-%m-%d %H:%M:%S.%6N")<=relative_time(now(), "+6mon")

View solution in original post

somesoni2
SplunkTrust
SplunkTrust

Just add following before |eval month.. line:

| where strptime(md_createdAt,"%Y-%m-%d %H:%M:%S.%6N")>now() AND strptime(md_createdAt,"%Y-%m-%d %H:%M:%S.%6N")<=relative_time(now(), "+6mon")

rkassabov
Path Finder

That worked, thank you!

0 Karma

DalJeanis
SplunkTrust
SplunkTrust

@rkassabov - We have converted the comment to an answer so you can accept it and the question will then show as closed. You can also (optionally) choose to upvote any comments or answers that you found particularly helpful. Thanks

0 Karma

somesoni2
SplunkTrust
SplunkTrust

md_createdAt should be 6 month in future from today's date?

0 Karma

rkassabov
Path Finder

thats correct

0 Karma
Get Updates on the Splunk Community!

Routing logs with Splunk OTel Collector for Kubernetes

The Splunk Distribution of the OpenTelemetry (OTel) Collector is a product that provides a way to ingest ...

Welcome to the Splunk Community!

(view in My Videos) We're so glad you're here! The Splunk Community is place to connect, learn, give back, and ...

Tech Talk | Elevating Digital Service Excellence: The Synergy of Splunk RUM & APM

Elevating Digital Service Excellence: The Synergy of Real User Monitoring and Application Performance ...