morechocolate
Technical User
I have been playing around for a while with the following
select dateadd(year,-1,(dateadd(day, -(datepart(day,somedate-1)), (dateadd(day,datediff(day,0,somedate),0)))))
which returns the last day of the previous month.
I need to return the previous year. For example if somedate is 12/31/2004, I want to return 12/31/2003. If I change the first day to year I get 12/01/2003
Thanks in advance for the help
select dateadd(year,-1,(dateadd(day, -(datepart(day,somedate-1)), (dateadd(day,datediff(day,0,somedate),0)))))
which returns the last day of the previous month.
I need to return the previous year. For example if somedate is 12/31/2004, I want to return 12/31/2003. If I change the first day to year I get 12/01/2003
Thanks in advance for the help