Splunk Search

How to compare an empty field with epoch time?

jam00
Explorer

Hello,

I have two fields: dateTimeA and dateTimeB.
When dateTimeA is empty, I add "NULL" string. Then I use strptime(dateTimeB) to get a numeric value based on epoch. How can I use dateTimeA to compare with a numeric value?

| eval dateTimeA=if((dateTimeA == "NULL"),dateTimeA,strptime(dateTimeA,"%Y-%m-%dT%H:%M:%S")) 
| eval dateTimeB=strptime(dateTimeB,"%Y-%m-%dT%H:%M:%S")
| where (dateTimeA < dateTimeB)

Thank you in advance.

0 Karma

koshyk
Super Champion

Please try to put 1 instead of NULL (or current time using now() )

 | eval dateTimeA=if((dateTimeA == "NULL"),"1",strptime(dateTimeA,"%Y-%m-%dT%H:%M:%S")) 
 | eval dateTimeB=strptime(dateTimeB,"%Y-%m-%dT%H:%M:%S")
 | where (dateTimeA < dateTimeB)

..

0 Karma

jam00
Explorer

dateTimeA field has dates or empties. If I use 1 that means one second, isn't it? So if I compare it with an epoch value near 1 the evaluation would be true... 1 < 1

0 Karma

jam00
Explorer

but I have an eval dateTimeA =coalesce(dateTimeA,"NULL") prior.

0 Karma
Get Updates on the Splunk Community!

Join Us for Splunk University and Get Your Bootcamp Game On!

If you know, you know! Splunk University is the vibe this summer so register today for bootcamps galore ...

.conf24 | Learning Tracks for Security, Observability, Platform, and Developers!

.conf24 is taking place at The Venetian in Las Vegas from June 11 - 14. Continue reading to learn about the ...

Announcing Scheduled Export GA for Dashboard Studio

We're excited to announce the general availability of Scheduled Export for Dashboard Studio. Starting in ...