Get Prior Month Number

EricLynnWright
EricLynnWright used Ask the Experts™
on
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....
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
select month(DATEADD (m , -1 , getdate() ))
AnujSQL Server DBA
Top Expert 2011

Commented:
SELECT DATEPART(mm,DATEADD(mm,-1,getdate()))

Author

Commented:
Thank you for the posts.

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

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial