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!

Splunk Observability as Code: From Zero to Dashboard

For the details on what Self-Service Observability and Observability as Code is, we have some awesome content ...

[Puzzles] Solve, Learn, Repeat: Character substitutions with Regular Expressions

This challenge was first posted on Slack #puzzles channelFor BORE at .conf23, we had a puzzle question which ...

Shape the Future of Splunk: Join the Product Research Lab!

Join the Splunk Product Research Lab and connect with us in the Slack channel #product-research-lab to get ...