Getting Data In

Splunk DB Connect 1: Why am I unable to apply the date range from the time range picker to filter my query?

kavyaa
Explorer

Hi,

I have connected to Splunk database. I have applied "dropdown input" filter on "Transdate column". When I click on "2011-03-22", it is showing "2011-03-22" data. Filter is working fine. Token name as "field1" & query is as below.

| dbquery "srdb" "SELECT   TransDate as '_time', ShowRoomCode as srcode , Num_of_Customers as totalcs FROM  Centro_Customer_Visit where Centro_Customer_Visit.TransDate
='$field1$'"

But I want to apply time range picker on "TransDate" column dynamically. I have tried, but I didn't get the date range.

I have data from 2011 to 2015. I want to fetch data from March 2011 to April 2011 using time range picker. Is it possible? How it will work? Please help me and send any documentation on this.......

Thanks in advance,
A.kavya.

0 Karma

acharlieh
Influencer

Actually this exact problem seems to have been posted with a couple of solutions in a previous answer: https://answers.splunk.com/answers/75999/splunk-db-connect-dbquery-inline-search-and-time-filtering-...

kavyaa
Explorer

I have seen that post. I have tried . But i did nt get correct data regarding selected input time filter. The code is follows. Please help me. Timestamp column "TransDate" has no time , only date values

Trandate coulmn have data format like this

2011-03-18
2011-06-26
2012-03-16
2012-05-21
2013-04-23
2013-07-14
2014-02-12
2014-03-29
2015-01-21

xml code is as follow

**<form>
  <label>sample_time</label>
  <fieldset submitButton="false" autoRun="true">
    <input type="time" token="TOKEN1" searchWhenChanged="true">
      <label>Selct Date</label>
      <default>
        <earliest>1300645800</earliest>
        <latest>1300905000</latest>
      </default>
    </input>
  </fieldset>
  <row>
    <panel>
      <table>
        <search>
          <query>| dbquery "CENTRO" "SELECT   TransDate , ShowRoomCode as srcode , Num_of_Customers as totalcs FROM  Centro_Customer_Visit  WHERE TransDate='$TOKEN1$'"</query>
          <earliest>1300645800</earliest>
          <latest>1332527400</latest>
        </search>
        <option name="wrap">true</option>
        <option name="rowNumbers">false</option>
        <option name="dataOverlayMode">none</option>
        <option name="drilldown">cell</option>
        <option name="count">10</option>
      </table>
    </panel>
  </row>
</form>**
0 Karma
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!

Take Action Automatically on Splunk Alerts with Red Hat Ansible Automation Platform

 Are you ready to revolutionize your IT operations? As digital transformation accelerates, the demand for ...

Calling All Security Pros: Ready to Race Through Boston?

Hey Splunkers, .conf25 is heading to Boston and we’re kicking things off with something bold, competitive, and ...

Beyond Detection: How Splunk and Cisco Integrated Security Platforms Transform ...

Financial services organizations face an impossible equation: maintain 99.9% uptime for mission-critical ...