Splunk Search

how to find differnce between epoch

karunagaraprabh
Explorer

When i try to find the difference between two epoc

1)find the days range i get blank values
2) and i need to filter only records where days =0

| eval printedA_epoch=strptime(printedtimestrampA,"%Y-%m-%dT%H:%M:%S.%Q"),printedB_epoch=strptime(printedtimestrampB,"%Y-%m-%dT%H:%M:%S.%Q")
| eval indextime =_indextime
| eval diffA=indextime-printedA_epoch, diffB=indextime-printedB_epoch
| eval daysA= round((diffA/86400),0) , daysB= round((diffB/86400),0)
| table host,printedA_epoch,printedB_epoch,indextime,diffA,diffB,daysA,daysB

karunagaraprabh_2-1592987307771.png

 

 

 

 

Labels (1)
0 Karma

rnowitzki
Builder

I just saw that you basically assked the question twice. 


https://community.splunk.com/t5/Splunk-Search/How-to-find-the-no-of-days-different-between-indexed-d...


You are on a good way with Giuseppe, so maybe you want to remove this duplicate.

--
Karma and/or Solution tagging appreciated.
0 Karma

rnowitzki
Builder

Hi @karunagaraprabh ,

Looking at your screenshot, it looks like printedA_epoch an printedA_epoch are MV (Multi Value) fields, is that correct?

So something in your SPL (that is not visible in your Screenshot) puts all the timestamps belonging to one host in a MV field. So the calculation does not work. You have to know/define which timestamp you want to calculate against the indextime, or (if you need to calculate against all) you have to change the SPL so that there is a line for each A and B timestamp pair.

We might need the full SPL and/or some sample data to help more detailed.


--
Karma and/or Solution tagging appreciated.
0 Karma
Get Updates on the Splunk Community!

Index This | What is broken 80% of the time by February?

December 2025 Edition   Hayyy Splunk Education Enthusiasts and the Eternally Curious!    We’re back with this ...

Unlock Faster Time-to-Value on Edge and Ingest Processor with New SPL2 Pipeline ...

Hello Splunk Community,   We're thrilled to share an exciting update that will help you manage your data more ...

Splunk MCP & Agentic AI: Machine Data Without Limits

Discover how the Splunk Model Context Protocol (MCP) Server can revolutionize the way your organization uses ...