Splunk Search

How to extract only date from the mentioned string

sbhatnagar88
Path Finder

Below is the kind of string i have and I want to extract only date from it.

Available string: 2019-02-24T16:05:37.000ZT16:05:37.000Z
Desired output: 2019-02-24

Thanks

Tags (1)
0 Karma
1 Solution

vnravikumar
Champion

Hi

Try like

rex field=specify_your_field "(?P<date>\d{4}-\d{2}-\d{2})"

View solution in original post

0 Karma

sbhatnagar88
Path Finder

That worked...Thanks.. In case I need time as well in my output?

0 Karma

vnravikumar
Champion

Hi @sbhatnagar88

Please try the following and accept the answer.

(?P<date>\d{4}-\d{2}-\d{2})T(?P<Time>\d{2}:\d{2}:\d{2})
0 Karma

sbhatnagar88
Path Finder

Thanks...That worked..

0 Karma

vnravikumar
Champion

Hi

Try like

rex field=specify_your_field "(?P<date>\d{4}-\d{2}-\d{2})"
0 Karma

vnravikumar
Champion

hi
please accept my answer.

0 Karma
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 ...