How to increase the month? - Mysql Send mail vote down 0 vote down 0 Views : 698
Tagged in : Mysql
To increase the month use DATE_ADD function.

Syntax:

ADDDATE(date,INTERVAL expr unit), ADDDATE(expr,days)


Example:
Create a table:

mysql> create table test (id int NOT NULL,xxxxx date);
Query OK, 0 rows affected (0.06 sec)


Insert the values:

mysql> insert into test values(1,'2008-08-07');
Query OK, 1 row affected (0.03 sec)

mysql> insert into test values(2,'2008-01-07');
Query OK, 1 row affected (0.00 sec)

mysql> insert into test values(3,'2008-12-22');
Query OK, 1 row affected (0.00 sec)


Select the values:

mysql> select * from test;



+----+------------+
| id | xxxxx |
+----+------------+
| 1 | 2008-08-07 |
| 2 | 2008-01-07 |
| 3 | 2008-12-22 |
+----+------------+
3 rows in set (0.00 sec)


If we want to increase the month use DATE_ADD function:

mysql> update test set xxxxx=DATE_ADD(xxxxx, INTERVAL 1 MONTH);
Query OK, 3 rows affected (0.01 sec)
Rows matched: 3 Changed: 3 Warnings: 0



mysql> select * from test;
+----+------------+
| id | xxxxx |
+----+------------+
| 1 | 2008-09-07 |
| 2 | 2008-02-07 |
| 3 | 2009-01-22 |
+----+------------+
3 rows in set (0.00 sec)


By - Sanju, On - 2008-07-23




    Login to add Comments .