Splunk Search

Add a number of hours to a search field?

balcv
Contributor

I have a field returned with some search data that contains a date and time in UTC.  I would like to be able to add 10 hours to the time.

a) Field contents(dateTime UTC):  2023-05-08T00:24:37.6079338Z

b) New field (Local dateTime):         2023-05-08 10:24:37.607

Is there a way to do the conversion from a) to b) in the search syntax?

Labels (1)
0 Karma

scelikok
SplunkTrust
SplunkTrust

Hi @balcv,

You can use below;

| eval newtime=strftime(strptime(datefield,"%Y-%m-%dT%H:%M:%S.%7QZ")+36000,"%Y-%m-%dT%H:%M:%S.%3QZ")
If this reply helps you an upvote and "Accept as Solution" is appreciated.

balcv
Contributor

Perfect thanks @scelikok 

0 Karma
Get Updates on the Splunk Community!

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

 Prepare to elevate your security operations with the powerful upgrade to Splunk Enterprise Security 8.x! This ...

Get Early Access to AI Playbook Authoring: Apply for the Alpha Private Preview ...

Passionate about security automation? Apply now to our AI Playbook Authoring Alpha private preview ...

Reduce and Transform Your Firewall Data with Splunk Data Management

Managing high-volume firewall data has always been a challenge. Noisy events and verbose traffic logs often ...