I’m struggling and I know I doing something stupid!!
If I try the following SQL to return the date 30/04/2009 I get ‘error converting 30/04/ to int’.
SELECT
DATEADD(YEAR,-1,'30/04/' + DATEPART(Year,GETDATE())),
Obviously I could just type 30/04/2009 but I want it to dynamically calculate ‘last year’ based on the current date.
Any suggestions as to what I am doing wrong? Another way to get the same result?
Ant
If I try the following SQL to return the date 30/04/2009 I get ‘error converting 30/04/ to int’.
SELECT
DATEADD(YEAR,-1,'30/04/' + DATEPART(Year,GETDATE())),
Obviously I could just type 30/04/2009 but I want it to dynamically calculate ‘last year’ based on the current date.
Any suggestions as to what I am doing wrong? Another way to get the same result?
Ant