H-SC
asked on
Get month name for previous month based on getdate()
Not sure why I can't get this one but ...
I have a query that I need to get the previous months name from the current getdate() ...
so for 03/31/2011 it would bring back February
I have a query that I need to get the previous months name from the current getdate() ...
so for 03/31/2011 it would bring back February
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
select datename(month,(dateadd(m, -1,cast(co nvert(char (7),getdat e(),23)+'- 01' as datetime))))
ASKER
ewanqoya,
yep, I noticed that, but not a big deal!! Many thanks for your help on this one
yep, I noticed that, but not a big deal!! Many thanks for your help on this one
this should work
select datename(month,dateadd(m,- 1,cast(con vert(char( 7),getdate (),23)+'-0 1' as datetime)))
select datename(month,dateadd(m,-
select DATENAME(MM, DATEADD(MM, -1, GETDATE()))