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
Get Updates on the Splunk Community!

Index This | When is October more than just the tenth month?

October 2025 Edition  Hayyy Splunk Education Enthusiasts and the Eternally Curious!   We’re back with this ...

Observe and Secure All Apps with Splunk

  Join Us for Our Next Tech Talk: Observe and Secure All Apps with SplunkAs organizations continue to innovate ...

What’s New & Next in Splunk SOAR

 Security teams today are dealing with more alerts, more tools, and more pressure than ever.  Join us for an ...