Splunk Search

How do you calculate the difference between two date/time with seconds.

alexspunkshell
Contributor

I am trying to calculate difference between two dates including seconds. But i am unable to find any logs.

Please help

My query

index=main source="https://test.ticketing-tool.com/" dv_state=* dv_priority="4 - Low" number=SIR0010241 | dedup number |eval startTime=strptime(dv_opened_at,"%Y-%m-%d %H:%M:%S:%3N")
|eval endTime=strptime(dv_sys_updated_on,"%Y-%m-%d %H:%M:%S:%3N")
|eval TimeDiff=tostring((endTime-startTime),"duration")
|table dv_opened_at dv_sys_updated_on TimeDiff, number

alexspunkshell_0-1606376006282.png

@soutamo @ITWhisperer  @gcusello @thambisetty @bowesmana @DalJeanis 

 

 

Labels (1)
Tags (1)
0 Karma
1 Solution

gcusello
SplunkTrust
SplunkTrust

Hi @alexspunkshell,

check the format of your dates: you didn't shared a sample of your logs but, viewing your screenshot, it  seems that the format isn't the one you used, but

%Y-%m-%d %H:%M:%S

If you share a sample I could be more detailed.

Ciao.

Giuseppe

View solution in original post

alexspunkshell
Contributor

I changed the format of Date, Month, Year and i am getting the result now. Thanks 

@gcusello  @ITWhisperer 

0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi @alexspunkshell,

good for you.

ciao and happy splunking.

Giuseppe

P.S.: Karma Points are appreciated by all the contributors 😉

ITWhisperer
SplunkTrust
SplunkTrust
index=main source="https://test.ticketing-tool.com/" dv_state=* dv_priority="4 - Low" number=SIR0010241 | dedup number |eval startTime=strptime(dv_opened_at,"%Y/%m/%d %H:%M:%S")
|eval endTime=strptime(dv_sys_updated_on,"%Y/%m/%d %H:%M:%S")
|eval TimeDiff=tostring((endTime-startTime),"duration")
|table dv_opened_at dv_sys_updated_on TimeDiff, number

gcusello
SplunkTrust
SplunkTrust

Hi @alexspunkshell,

check the format of your dates: you didn't shared a sample of your logs but, viewing your screenshot, it  seems that the format isn't the one you used, but

%Y-%m-%d %H:%M:%S

If you share a sample I could be more detailed.

Ciao.

Giuseppe

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