select year(DATEADD(m,-1,(month(@intMonth)+year(@intYear))))
select year(DATEADD(m,-1,(month(1)+year(2006))))
i am using the above dateadd funtion. i use two variables in my query intMonth and intYear.
I want to use the dateadd function to return the year based on the month and year passed in as parameters.
basically if the year is 2006 and the month is jan (01) i want the year to be 2005 as the function should take one month away from the month and yeat thus giving 12/2005. i just need to be able to say that if the month is jan and the year is 2006 then the year returned from this query should be 2005. before jan 2006 is dec (2005). i have to use the two variables intMonth and intYear but i cant figure out how to pass these to the dateadd function and get the right year back,
the select statement above returns 1905 - taking one from the month and 100 from the year
would really appreciate any help with this one!
thanks.
select year(DATEADD(m,-1,(month(1)+year(2006))))
i am using the above dateadd funtion. i use two variables in my query intMonth and intYear.
I want to use the dateadd function to return the year based on the month and year passed in as parameters.
basically if the year is 2006 and the month is jan (01) i want the year to be 2005 as the function should take one month away from the month and yeat thus giving 12/2005. i just need to be able to say that if the month is jan and the year is 2006 then the year returned from this query should be 2005. before jan 2006 is dec (2005). i have to use the two variables intMonth and intYear but i cant figure out how to pass these to the dateadd function and get the right year back,
the select statement above returns 1905 - taking one from the month and 100 from the year
would really appreciate any help with this one!
thanks.