Mysql Date Previous Month

Mysql Date Previous Month is used to return the current and previous value of the month.

Mysql Date Previous Month

Mysql Date Previous Month

     

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)