>Hi
>
>I'm being passed a date via a csv file.
>
>I want to insert into my database the previous October 1st of that date minus 4 years.
>
>So if my date is 1st January 2011 I'd want the 1st October 2006
>
>Any ideas on how I could get that.
>
>Thnaks
Do you just want to subtract 4 years from current date?
If so,
declare @PrevDate date
set @PrevDate = dateadd(year, -4, cast(CURRENT_TIMESTAMP as DATE))
If you always want October 1, then
select CONVERT(datetime,ltrim(year(CURRENT_TIMESTAMP)-4) + '1001') as PreviousDate
If it's not broken, fix it until it is.
My Blog