calculate specific date last year

anthonys

Registered User.
Local time
Today, 21:30
Joined
Feb 4, 2005
Messages
40
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 you want today's date last year just use:

DateAdd("yyyy", -1, Date())
 

Users who are viewing this thread

Back
Top Bottom