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!

[Puzzles] Solve, Learn, Repeat: Dynamic formatting from XML events

This challenge was first posted on Slack #puzzles channelFor a previous puzzle, I needed a set of fixed-length ...

Enter the Agentic Era with Splunk AI Assistant for SPL 1.4

  &#x1f680; Your data just got a serious AI upgrade — are you ready? Say hello to the Agentic Era with the ...

Stronger Security with Federated Search for S3, GCP SQL & Australian Threat ...

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...