Getting Data In

how to change the date format in splunk?

shankarananthth
Explorer

I have the date format like 2016-03-09 11:43:40.870 ( "%Y-%m-%d %H:%M:%S)

But i want to change the above date format like 03-09-2016 11:43:40.870 (%m-%d-%Y %H:%M:%S)

Thanks in advance

Tags (2)

woodcock
Esteemed Legend

At search time you can do this:

| eval newDate=strftime(strptime(oldDate, "%Y-%m-%d %H:%M:%S"), "%m-%d-%Y %H:%M:%S")

or like this:

| rex mode=sed field=oldDate "s/(\d{4})-(\d+-\d+) /\2-\1 /"

At index time, like this:

SEDCMD-englishDateToUSA "s/(\d{4})-(\d+-\d+) /\2-\1 /"

richgalloway
SplunkTrust
SplunkTrust

Try this:

... | eval date=strftime(strptime(date,"%Y-%m-%d %H:%M:%S"), "%m-%d-%Y %H:%M:%S") | ...
---
If this reply helps you, Karma would be appreciated.
Get Updates on the Splunk Community!

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!

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

New in Observability Cloud - Explicit Bucket Histograms

Splunk introduces native support for histograms as a metric data type within Observability Cloud with Explicit ...