Splunk Search

How to calculate days for past and future days?

DataOrg
Builder

Hello,

I want to calculate the days in difference like below like future days should be in positive and past days should be negative

i tried eval diff=(now()-_time) and did strftime(diff,"%D") but here all are in positive days. i want the past days in negative

Date Difference in Days  
04-02-2022 -5  
05-02-2022 -4  
06-02-2022 -3  
07-02-2022 -2  
08-02-2022 -1  
09-02-2022 0 Today Date
10-02-2022 1  
11-02-2022 2  
12-02-2022 3  
13-02-2022 4  
Labels (4)
Tags (3)
0 Karma
1 Solution

ITWhisperer
SplunkTrust
SplunkTrust
| eval diff=floor((_time-now())/(60*60*24))

View solution in original post

ITWhisperer
SplunkTrust
SplunkTrust
| eval diff=floor((_time-now())/(60*60*24))
Get Updates on the Splunk Community!

Index This | I am a number, but when you add ‘G’ to me, I go away. What number am I?

March 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...