Splunk Search

How to do data extraction?

mistydennis
Communicator

I'm having trouble extracting some dates from a date field. Certain assets were provided with a generic date, and I can't seem to extract the date for these events.

Sample data:

lastscan newdate
2022-08-10T06:51:33.874Z 2022-08-10
2022-08-10T00:06:19.920Z 2022-08-10
1969-12-31T23:59:59.999Z  

 

SPL:
| eval newdate=strptime(lastscan,"%Y-%m-%d")
| eval newdate=strftime(newdate,"%Y-%m-%d")

As you can see, the events with the 1969 date are not extracting as expected and I'm getting no results for the "newdate" field. 

Any thoughts on how I can extract the date from the 1969 events?

Labels (2)
0 Karma
1 Solution

ITWhisperer
SplunkTrust
SplunkTrust

Epoch date times start from 1970 so if you are prepared to consider 1969-12-31T23:59:59.999 as 1970-01-01T00:00:00.000, then you could use fillnull

| eval newdate=strptime(lastscan,"%Y-%m-%d")
| fillnull value=0 newdate
| eval newdate=strftime(newdate,"%Y-%m-%d")

View solution in original post

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

Epoch date times start from 1970 so if you are prepared to consider 1969-12-31T23:59:59.999 as 1970-01-01T00:00:00.000, then you could use fillnull

| eval newdate=strptime(lastscan,"%Y-%m-%d")
| fillnull value=0 newdate
| eval newdate=strftime(newdate,"%Y-%m-%d")
0 Karma
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Agent Mode Engaged! Enchaining Agentic Operations with Splunk AI Assistant 2.0

    Are you ready to transform how your team handles complex data requests? We invite you to our upcoming ...

Announcing Modern Navigation: A New Era of Splunk User Experience

We are excited to introduce the Modern Navigation feature in the Splunk Platform, available to both cloud and ...

Modernize your Splunk Apps – Introducing Python 3.13 in Splunk

We are excited to announce that the upcoming releases of Splunk Enterprise 10.2.x and Splunk Cloud Platform ...