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!

Enter the Splunk Community Dashboard Challenge for Your Chance to Win!

The Splunk Community Dashboard Challenge is underway! This is your chance to showcase your skills in creating ...

.conf24 | Session Scheduler is Live!!

.conf24 is happening June 11 - 14 in Las Vegas, and we are thrilled to announce that the conference catalog ...

Introducing the Splunk Community Dashboard Challenge!

Welcome to Splunk Community Dashboard Challenge! This is your chance to showcase your skills in creating ...