Link to home
Start Free TrialLog in
Avatar of H-SC
H-SCFlag for United States of America

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
ASKER CERTIFIED SOLUTION
Avatar of Ephraim Wangoya
Ephraim Wangoya
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I missed a comma

select DATENAME(MM, DATEADD(MM, -1, GETDATE()))
select datename(month,(dateadd(m,-1,cast(convert(char(7),getdate(),23)+'-01' as datetime))))
Avatar of H-SC

ASKER

ewanqoya,

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(convert(char(7),getdate(),23)+'-01' as datetime)))