Splunk Search

Why is _time storing incorrect value?

angelinealex
Communicator

I use the below saved search and scheduled it and enabled the summary index.

| dbxquery connection=connectionname query="select startdatetime, enddatetime from tablename where enddatetime > ? AND enddatetime < ?"
 [| makeresults 
    | appendcols 
        [| inputlookup kvstorelookup 
           ....
           ....
          | eval starttime="2018-07-19 23:00:01"
          | eval endtime="2018-07-19 23:15:00"
          | eval daterange=starttime.",".endtime
          | rename daterange as params
          | fields params]] 
| eval _time=enddatetime
|fields _time, startdatetime, enddatetime
|table _time, startdatetime, enddatetime

When I run the query manually it shows _time as exactly same as enddatetime value.
But when it runs through scheduler _time is always stored as "2018-07-19 00:59:59"

I am not sure why this is happening. Can someone please help?

0 Karma
1 Solution

angelinealex
Communicator

Fixed the issue. Missed to convert the time to epoch before storing in _time.

Below line fixed the issue.
| eval _time=strptime(enddatetime,"%Y-%m-%d %H:%M:%S.%1N")

View solution in original post

0 Karma

angelinealex
Communicator

Fixed the issue. Missed to convert the time to epoch before storing in _time.

Below line fixed the issue.
| eval _time=strptime(enddatetime,"%Y-%m-%d %H:%M:%S.%1N")

0 Karma

manish_singh_77
Builder

Don't use _time in your query and then try to compare the searches...Let me know if it works for you...

0 Karma

angelinealex
Communicator

I tried, it didnt work. Still _time value stored as "2018-07-19 00:59:59"

0 Karma

jcoates
Communicator

I think you need to do an input instead to control time, http://docs.splunk.com/Documentation/DBX/3.1.3/DeployDBX/Createandmanagedatabaseinputs

Have you tried naming the time column to _time in your SQL?

0 Karma

angelinealex
Communicator

you mean enddatetime as _time in select query? If so, yes I did. But it didnt work.

I also tried removing _time field from this saved search. But still the _time value stored as "2018-07-19 00:59:59"

0 Karma
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

SOK it to Me: Top 3 Benefits of Using Splunk Operator on Kubernetes that’ll Make ...

    Thursday, July 9, 2026  |  11:00AM–12:00PM PDT Duration: 1 hour (includes Q&A) Managing can feel like a ...

Upgrade Prep for 10.4, Network Observability Deep Dives, and More from Splunk Lantern

Splunk Lantern is Splunk’s customer success center that provides practical guidance from Splunk experts on key ...

Splunk Developer Day announcements: AI agents, MCP tools, Forecasting, and Custom ...

Splunk Developer Day was packed with product and platform updates for developers building in the AI ...