
- Learn MySQL
- MySQL - Home
- MySQL - Introduction
- MySQL - Installation
- MySQL - Administration
- MySQL - PHP Syntax
- MySQL - Connection
- MySQL - Create Database
- MySQL - Drop Database
- MySQL - Select Database
- MySQL - Data Types
- MySQL - Create Tables
- MySQL - Drop Tables
- MySQL - Insert Query
- MySQL - Select Query
- MySQL - Where Clause
- MySQL - Update Query
- MySQL - Delete Query
- MySQL - Like Clause
- MySQL - Sorting Results
- MySQL - Using Join
- MySQL - NULL Values
- MySQL - Regexps
- MySQL - Transactions
- MySQL - Alter Command
- MySQL - Indexes
- MySQL - Temporary Tables
- MySQL - Clone Tables
- MySQL - Database Info
- MySQL - Using Sequences
- MySQL - Handling Duplicates
- MySQL - SQL Injection
- MySQL - Database Export
- MySQL - Database Import
Add two weeks to a date in MySQL?
To add two weeks to a date in MySQL, use DATE_ADD() −
insert into yourTableName(yourColumnName) values(date_add(now(),interval 2 week));
Let us first create a table −
mysql> create table DemoTable ( Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, ShippingDate datetime ); Query OK, 0 rows affected (0.62 sec)
Following is the query to get the current date −
mysql> select now(); +-----------------------+ | now() | +-----------------------+ | 2019-06-02 10 :36 :49 | +-----------------------+ 1 row in set (0.00 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable(ShippingDate) values(date_add(now(),interval 2 week)); Query OK, 1 row affected (0.22 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable;
Output
+----+-----------------------+ | Id | ShippingDate | +----+-----------------------+ | 1 | 2019-06-16 10 :37 :24 | +----+-----------------------+ 1 row in set (0.00 sec)
- Related Articles
- How to Add or Subtract Weeks to a Date in Excel?
- MySQL query to select date >= current date - 3 weeks?
- MySQL add days to a date?
- MySQL time period query to fetch date records from interval of 14 weeks from current date?
- How to add a day to the date in MySQL?
- How to add a year and two days to a date with a single MySQL query?
- Add 30 days to date in a MySQL table with arrival date records
- Add 11 days to current date in MySQL
- How to add 1 day to the date in MySQL?
- Add a single year to all the date records in a MySQL table column
- How to add current date to an existing MySQL table?
- Add DATE and TIME fields to get DATETIME field in MySQL?
- Add some months to current date using Java with MySQL?
- MySQL query to fetch records before currentdate + 2 weeks?
- How can we add a time interval to date stored in a column of MySQL table?

Advertisements