Splunk Search

How to extract a field with date string values?

ashishlal82
Explorer

I extracted a field SNDateCreated (regex shown below), the values in this field are represented as strings.

index="win" source="ad" | rex "wCreated=\d{1,2}\:\d{1,2}\.\d{1,2}\s\w+\,\s\w+\s(?.*?)\s" | table SNDateCreated

My goal is to present SNDateCreated with dates 14 days back from now, it should be sorting based on the values in SNDateCreated rather than event dates.
Expected:
03/08/2018
03/07/2018
03/05/2018
..... going 14 days back.

0 Karma
1 Solution

elliotproebstel
Champion

If you have successfully extracted the dates into SNDateCreated and want to sort reverse-chronologically and retain only those in the last 14 days:

your search
| where date>=strftime(relative_time(now(), "-14d"), "%m/%d/%Y") 
| sort - date

View solution in original post

0 Karma

elliotproebstel
Champion

If you have successfully extracted the dates into SNDateCreated and want to sort reverse-chronologically and retain only those in the last 14 days:

your search
| where date>=strftime(relative_time(now(), "-14d"), "%m/%d/%Y") 
| sort - date
0 Karma
Get Updates on the Splunk Community!

Stay Connected: Your Guide to May Tech Talks, Office Hours, and Webinars!

Take a look below to explore our upcoming Community Office Hours, Tech Talks, and Webinars this month. This ...

They're back! Join the SplunkTrust and MVP at .conf24

With our highly anticipated annual conference, .conf, comes the fez-wearers you can trust! The SplunkTrust, as ...

Enterprise Security Content Update (ESCU) | New Releases

Last month, the Splunk Threat Research Team had two releases of new security content via the Enterprise ...