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!

Enterprise Security Content Update (ESCU) | New Releases

In December, the Splunk Threat Research Team had 1 release of new security content via the Enterprise Security ...

Why am I not seeing the finding in Splunk Enterprise Security Analyst Queue?

(This is the first of a series of 2 blogs). Splunk Enterprise Security is a fantastic tool that offers robust ...

Index This | What are the 12 Days of Splunk-mas?

December 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...