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!

Index This | What goes away as soon as you talk about it?

May 2025 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with this month’s ...

What's New in Splunk Observability Cloud and Splunk AppDynamics - May 2025

This month, we’re delivering several new innovations in Splunk Observability Cloud and Splunk AppDynamics ...

Getting Started with Splunk Artificial Intelligence, Insights for Nonprofits, and ...

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