Casey ScriptFu Pharr
Casey ScriptFu Pharr

Reputation: 1680

How to pass a sql stored procedure a string with DatetIme.Today() in it

I have a stored procedure that uses kendo params to filter the results. I would like to use this same procedure to run a report in SSRS. The parameter is shown below:

        @pFilter = N'DueDate~gte~datetime2017-12-26T11-23-21~DueDate~lte~datetime2018-01-25T11-23-21~',     

Here is what i need to be able ot pass it by bulding the param string but with a current dat calculation in it so the stored procedure can be called via Report Builder report.

Needed:

    @pFilter = N'DueDate~gte~datetime' DATEADD(day, 90, MAX(GETDATE())) + '~DueDate~lte~datetime2018-01-25T11-23-21~',      

Is this possible and if so, can anyone point me in a direction to understand how to acomplish this?

-Thanks in advance-

Upvotes: 0

Views: 237

Answers (1)

StevenWhite
StevenWhite

Reputation: 6034

It would make a lot more sense if your procedure took two date parameters. But given the restriction, the expression should be:

="DueDate~gte~datetime" & DATEADD("d", 90, Today) & "~DueDate~lte~datetime2018-01-25T11-23-21~"

This assumes that your procedure can accept the standard date format as opposed to the format in your example. If not, you'll need to reformat it or update the procedure to accept this.

Upvotes: 1

Related Questions