Dashboards & Visualizations

How to compare a field value that contains date only to today's date?

maurkb
New Member

I have looked at all of the date comparison questions/answers but cannot find an answer to this question. I have a field (StandInDay) which contains only the date, no time (StandInDay=2016-12-01). In my dashboard, I want a panel that displays the number of transactions in which this StandInDay value matches today's date (among other criteria). So basically, the number of these transactions in which the StandInDay is equal to today, but I cannot seem to get it to work. I have tried converting to epoch and comparing to now() but that doesn't work. Any suggestions?

0 Karma

lguinn2
Legend

Today's date is not a single epoch time value, but a range of values, so comparing to now() - which is the precise start time of the search - isn't going to work.

The easiest way to do this is to convert now() to a text field in the same format as StandInDay, like this

yoursearchhere
| eval today=strftime(now(),"%Y-%m-%d")
| where StandInDay=today

This should do the trick.

Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Can’t Make It to Boston? Stream .conf25 and Learn with Haya Husain

Boston may be buzzing this September with Splunk University and .conf25, but you don’t have to pack a bag to ...

Splunk Lantern’s Guide to The Most Popular .conf25 Sessions

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...

Unlock What’s Next: The Splunk Cloud Platform at .conf25

In just a few days, Boston will be buzzing as the Splunk team and thousands of community members come together ...