Reporting

Convert non-standard date field to $m/$d/$y at search time

asofo
Path Finder

Hi, I'm pulling Tenable IO logs into Splunk and there is a field names first_found in regard to a vulnerability. The format is UNIX. I'd like to take that field data and create a new field and format it as $m/$d/$y at search time. I've scoured this site and reddit and can't get it to work.

Here is an example:

first_found = 2020-05-27T04:17:39.159Z

would like to create:

new_date = 5/27/2020

I've tried the below, but with no luck:

(search query) | convert timeformat="%m/%d/%y" ctime(first_found) AS new_date

Any help would be appreciated.

0 Karma

richgalloway
SplunkTrust
SplunkTrust

To convert a time string into a different format use strptime() to convert it into epoch form and strftime() to convert to the new string format.

| eval new_date = strftime(strptime(first_found, "%Y-%m-%dT%H:%M:%S.%3N%Z"),  %m/%d/%Y)
---
If this reply helps you, Karma would be appreciated.
0 Karma
Get Updates on the Splunk Community!

Tech Talk Recap | Mastering Threat Hunting

Mastering Threat HuntingDive into the world of threat hunting, exploring the key differences between ...

Observability for AI Applications: Troubleshooting Latency

If you’re working with proprietary company data, you’re probably going to have a locally hosted LLM or many ...

Splunk AI Assistant for SPL vs. ChatGPT: Which One is Better?

In the age of AI, every tool promises to make our lives easier. From summarizing content to writing code, ...