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!

See just what you’ve been missing | Observability tracks at Splunk University

Looking to sharpen your observability skills so you can better understand how to collect and analyze data from ...

Weezer at .conf25? Say it ain’t so!

Hello Splunkers, The countdown to .conf25 is on-and we've just turned up the volume! We're thrilled to ...

How SC4S Makes Suricata Logs Ingestion Simple

Network security monitoring has become increasingly critical for organizations of all sizes. Splunk has ...