Link to home
Start Free TrialLog in
Avatar of EricLynnWright
EricLynnWrightFlag for United States of America

asked on

Get Prior Month Number

Seeing if anyone has SQL on how to get the prior month (as a number) by using today's date.


So for this month, it would come back as 4.  In january, it would come back as 12.

etc....
ASKER CERTIFIED SOLUTION
Avatar of Andrew Crofts
Andrew Crofts
Flag of Ukraine 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
SELECT DATEPART(mm,DATEADD(mm,-1,getdate()))
Avatar of EricLynnWright

ASKER

Thank you for the posts.

anujnb - he beat you by just a minute.  But I certainly appreciate the help.