RangerLad
asked on
Syntax question for SQL Stored Procedure
Hi Experts
I need to create a date string then do a test against it with another date within a SQL Stored Procedure. So I am first of all extracting the Year I want into a variable called @FinancialYr then need to set a date of 1/4/@FinancialYr.
My existing code is;
set @FinancialYrStart = cast(("01/04/"&@FinancialY r) as datetime)
print convert(datetime, @FinancialYrStart)
The second line is where I am trying to view the result. I am getting an error ;
"Syntax error converting the varchar value '01/04/' to a column of data type int."
Can anyone give me an idea where the syntax is falling down ?
Many thanks
RangerLad
I need to create a date string then do a test against it with another date within a SQL Stored Procedure. So I am first of all extracting the Year I want into a variable called @FinancialYr then need to set a date of 1/4/@FinancialYr.
My existing code is;
set @FinancialYrStart = cast(("01/04/"&@FinancialY
print convert(datetime, @FinancialYrStart)
The second line is where I am trying to view the result. I am getting an error ;
"Syntax error converting the varchar value '01/04/' to a column of data type int."
Can anyone give me an idea where the syntax is falling down ?
Many thanks
RangerLad
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
RangerLad