Splunk Dev

Passing current date as parameter/s to dbxquery stored proc

Ana01
Loves-to-Learn Everything

Hi,
I have a SQL DB stored procedure that accepts a datetime input.
The idea is to run this as a saved report daily and overwrite the output lookup table with results.

The following works when I hardcode the date in the params field: 

| dbxquery connection="MyDBConnection" query="{call MyStoredProc(?)}" params="2023-07-09"

Now, I need to use a variable in the params field to pass the current date dynamically.
| eval currentDate = strftime(now(), "%Y-%m-%d")
| dbxquery connection="MyDBConnection" query="{call MyStoredProc(?)}" params=\"$currentDate$\"

With the above I keep getting an error :
om.microsoft.sqlserver.jdbc.SQLServerException: Error converting data type nvarchar to datetime2.

 

So how do I get the current date as a variable, and use it as an input parameter for a stored proc? Thanks!

Labels (2)
0 Karma
Get Updates on the Splunk Community!

Splunk at Cisco Live 2025: Learning, Innovation, and a Little Bit of Mr. Brightside

Pack your bags (and maybe your dancing shoes)—Cisco Live is heading to San Diego, June 8–12, 2025, and Splunk ...

Splunk App Dev Community Updates – What’s New and What’s Next

Welcome to your go-to roundup of everything happening in the Splunk App Dev Community! Whether you're building ...

The Latest Cisco Integrations With Splunk Platform!

Join us for an exciting tech talk where we’ll explore the latest integrations in Cisco + Splunk! We’ve ...