My goal is to create a procedure in SQL Server , which has by default two variables, one with the start date of (hoje - 3 anos)
and another as the end date equal to hoje
. I already use for other operations (for example a between) this format to get the date.
I tried to do this:
Create procedure EXTRAÇÃO_SD1_SD2
-- Receber data formato 'AAAMMDD'
@dataini VARCHAR(MAX) = REPLACE(CONVERT(char(10), GetDate()-1080,126),'-','')
@datafim as varchar(10) = REPLACE(CONVERT(char(10), GetDate(),126),'-','')
As
Begin
-- continua procedure
But I get the error below when I run
Msg 102, Level 15, State 1, Procedure EXTRACTION_SD1_SD2, Line 5 [Batch Start Line 0] Incorrect syntax near '('.
What's wrong?