Link to home
Start Free TrialLog in
Avatar of RangerLad
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/"&@FinancialYr) 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
ASKER CERTIFIED SOLUTION
Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of RangerLad
RangerLad

ASKER

Thanks angelIII thats exactly the result I was looking for, many thanks

RangerLad