1

I've built a procedure I need to run it for the last 60 days. I can't seem to figure it out.

I've got the following date parameters statements for the parameters and they return

select dateadd(Day, -60, getdate()), dateadd(Day, -1, getdate())

enter image description here

The code itself adjusts the end date to be at the very end of the day. 23:59:59.

When I do this

exec LRP_PROC 
         @start_Dt = dateadd(Day, -60, getdate()),
         @end_dt = dateadd(Day, -1, getdate()),
         @mode = 0

I get the following error

enter image description here

I can't figure out what I'm doing wrong.

Thank you.

1 Answer 1

2

SQL Server does not permit arbitrary expressions to be passed as stored procedure parameters. You need to declare and assign local variables before calling the proc.

eg

declare @start datetime = dateadd(Day, -60, getdate());
declare @end datetime = dateadd(Day, -1, getdate());

exec LRP_PROC @start_Dt=@start, @end_dt=@end, @mode = 0;
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.