Mysql Date Previous Month is used to return the current and previous value of the month.
Understand with Example
The Tutorial illustrate an example that help you to describe Previous Month value. To understand this, we have a month (now( )) that return you current month value.
Query for finding current month:-
mysql> select month(now()) as CurrentMonth; |
Output:-
+--------------+ | CurrentMonth | +--------------+ | 12 | +--------------+ 1 row in set (0.00 sec) |
Query for finding Previous month:-
Once you are able to find the current month, you can easily find the previous month before the current month. The Query month(now( )) -1 return you the previous month value precede the current month.
month(now( ))-1 : The month(now( )) -1 return you the previous month before the current month.
mysql> select month(now())-1 as PreviousMonth; |
Output:-
+---------------+ | PreviousMonth | +---------------+ | 11 | +---------------+ 1 row in set (0.00 sec) |
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.
Ask Questions? Discuss: Mysql Date Previous Month
Post your Comment