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 for AI

Don’t miss out on an exciting Tech Talk on Splunk Observability for AI!Discover how Splunk’s agentic AI ...

Splunk Enterprise Security 8.x: The Essential Upgrade for Threat Detection, ...

Watch On Demand the Tech Talk on November 6 at 11AM PT, and empower your SOC to reach new heights! Duration: ...

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