Splunk Enterprise

Convert just the Time from _time to epoch

tmontney
Builder

I've seen a lot of questions asking to get just the date from date/time stamp and convert to epoch. I want to do it for time.

eval Time=strptime(strftime(_time, "%H:%M:%S"), "%H:%M:%S")

I've tried this, but the date still seems to go with it. Epoch returns date with it. For instance, it returns 1491949028. I'm expecting a epoch value between 0 and 86400, where the date is 1/1/1970. My point is I want to determine if the date is between the hours of 8 AM and 5 PM.

0 Karma

DMohn
Motivator

The epoch will always contain date and time, as this is the definition of the epoch format. If you just want to evaluate the hours, you can use the following search string:

<your base search> | eval hours=strftime(_time,"%H") | where hours > 7 AND hours < 18
0 Karma

masonmorales
Influencer

Wouldn't the date_hour field work for this?

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