Splunk Search

Convert 210910085155 to yymmddhhmmss or dd/mm/yy hh:mm:ss

peterk
New Member

Hi 

Need help converting 210910085155 to yymmddhhmmss

index=mydata
| eval fields=split(EventMsg,",")
| eval file_string=mvindex(fields,0)
| eval CreatedDate=mvindex(fields,17)
| table CreatedDate

CreatedDate =210910085155 need to covert it to Date

0 Karma

richgalloway
SplunkTrust
SplunkTrust

Perhaps the easiest way is to use strptime/strftime.

index=mydata
| eval fields=split(EventMsg,",")
| eval file_string=mvindex(fields,0)
| eval CreatedDate=mvindex(fields,17)
| eval Date = strftime(strptime(CreatedDate, "%y%m%d%h%m%s"), "%d/%m/%y %H:%M:%S")
---
If this reply helps you, Karma would be appreciated.
0 Karma

Sharzi
Explorer

Try:

| eval Date=strftime(CreatedDate/1000, "%y%m%d%H%M%S")

or

| eval Date=strftime(CreatedDate/1000, "%d/%m/%y %H:%M:%S")

 

Also, you can use either %y or %Y for the year.

0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.
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, ...