"Wharfrat" <wh********@comcast.net> wrote in message
news:As********************@comcast.com...
Hey all,
I have a query that pulls data based on the month. I'm using
MONTHNAME(CURDATE()) to get the current month. I need to get the
previous month. Is there a way to do this using MONTHNAME?
thanks in advance
No! You don't use MONTHNAME() to calculate what the previous month was. To
do that you want to subtract a month from the current month is. The month
before this one can always be determined by:
SELECT DATE_ADD(CURDATE(), INTERVAL -1 MONTH)
And if you want to see it as a name instead of a number you can enclose that
calculation with MONTHNAME() :
SELECT MONTHNAME(DATE_ADD(CURDATE(), INTERVAL -1 MONTH))
Thomas Bartkus