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!

Announcing Scheduled Export GA for Dashboard Studio

We're excited to announce the general availability of Scheduled Export for Dashboard Studio. Starting in ...

Extending Observability Content to Splunk Cloud

Watch Now!   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to leverage ...

More Control Over Your Monitoring Costs with Archived Metrics GA in US-AWS!

What if there was a way you could keep all the metrics data you need while saving on storage costs?This is now ...