Dashboards & Visualizations

How do I count time differently than 00:00 ~ 24:00?

hyungjoon
New Member

Question)
If my store is open through 1pm~2am and I want to see how many chickens I sold on one day, Splunk would count the
chickens I sold from 12am~2am to the next day and count the chickens I sold the day before.

I want to make a line chart of this but the calculations are wrong because of this.

Can anybody help?

0 Karma
1 Solution

nswondem
Path Finder

Hi hyngjoon,

The goal would be to identify whether an event occurred yesterday or today, then compare the datehours.

  1. Calculate the start of yesterday
  2. Calculate the start of today
  3. Get the datehour using strftime
  4. Convert the hr to a number (since it is a string)
  5. Determine whether the event time is yesterday and the hour is after 12pm OR whether the event time is today and the hour is before 2am.

Nadine
...
| eval yesterday=relative_time(now(), "-1d@d")
| eval today=relative_time(now(), "@d")
| eval hr=strftime(_time, "%H")
| eval hr=tonumber(hr)
| where (_time >= yesterday AND hr > 12) OR (_time >= today AND hr <=2)

View solution in original post

0 Karma

nswondem
Path Finder

Hi hyngjoon,

The goal would be to identify whether an event occurred yesterday or today, then compare the datehours.

  1. Calculate the start of yesterday
  2. Calculate the start of today
  3. Get the datehour using strftime
  4. Convert the hr to a number (since it is a string)
  5. Determine whether the event time is yesterday and the hour is after 12pm OR whether the event time is today and the hour is before 2am.

Nadine
...
| eval yesterday=relative_time(now(), "-1d@d")
| eval today=relative_time(now(), "@d")
| eval hr=strftime(_time, "%H")
| eval hr=tonumber(hr)
| where (_time >= yesterday AND hr > 12) OR (_time >= today AND hr <=2)

0 Karma
Get Updates on the Splunk Community!

Data Management Digest – November 2025

  Welcome to the inaugural edition of Data Management Digest! As your trusted partner in data innovation, the ...

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