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
Revered Legend

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
Revered Legend

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
Legend

@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
Revered Legend

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!

Join Us for Splunk University and Get Your Bootcamp Game On!

If you know, you know! Splunk University is the vibe this summer so register today for bootcamps galore ...

.conf24 | Learning Tracks for Security, Observability, Platform, and Developers!

.conf24 is taking place at The Venetian in Las Vegas from June 11 - 14. Continue reading to learn about the ...

Announcing Scheduled Export GA for Dashboard Studio

We're excited to announce the general availability of Scheduled Export for Dashboard Studio. Starting in ...