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 Mobile: Your Brand-New Home Screen

Meet Your New Mobile Hub  Hello Splunk Community!  Staying connected to your data—no matter where you are—is ...

Introducing Value Insights (Beta): Understand the Business Impact your organization ...

Real progress on your strategic priorities starts with knowing the business outcomes your teams are delivering ...

Enterprise Security (ES) Essentials 8.3 is Now GA — Smarter Detections, Faster ...

As of today, Enterprise Security (ES) Essentials 8.3 is now generally available, helping SOC teams simplify ...