Splunk Search

How to include "-" in between a field value?

vrmandadi
Builder

I have a field lastrundate which has values 20190623 , 20190624 , 20190626.
I want to include an "-" in between them to make the value look like 2019-06-23 ,2019-06-24 ,2019-06-26.

I read the sed command does something similar.
Any inputs?

Thanks in Advance

0 Karma
1 Solution

gcusello
SplunkTrust
SplunkTrust

Hi vrmandadi,
these values seems to be dates so you can use the date transforming functions, something like this:

| eval lastrundate=strftime(strptime(lastrundate,"%Y%m%d"),"%Y-%m-%d")

Bye.
Giuseppe

View solution in original post

gcusello
SplunkTrust
SplunkTrust

Hi vrmandadi,
these values seems to be dates so you can use the date transforming functions, something like this:

| eval lastrundate=strftime(strptime(lastrundate,"%Y%m%d"),"%Y-%m-%d")

Bye.
Giuseppe

vrmandadi
Builder

Thank You that worked .Can you move this comment to the answer section.I will accept it

0 Karma
Get Updates on the Splunk Community!

What's new in Splunk Cloud Platform 9.1.2312?

Hi Splunky people! We are excited to share the newest updates in Splunk Cloud Platform 9.1.2312! Analysts can ...

What’s New in Splunk Security Essentials 3.8.0?

Splunk Security Essentials (SSE) is an app that can amplify the power of your existing Splunk Cloud Platform, ...

Let’s Get You Certified – Vegas-Style at .conf24

Are you ready to level up your Splunk game? Then, let’s get you certified live at .conf24 – our annual user ...