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

Labels (1)
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!

Announcing Scheduled Export GA for Dashboard Studio

We're excited to announce the general availability of Scheduled Export for Dashboard Studio. Starting in ...

Extending Observability Content to Splunk Cloud

Watch Now!   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to leverage ...

More Control Over Your Monitoring Costs with Archived Metrics GA in US-AWS!

What if there was a way you could keep all the metrics data you need while saving on storage costs?This is now ...