Last updated 2 years ago
If you have a problem like How to increase the number of days for a date in a MySQL database? We will solve this like below example.
There exists a table in our database named "inventory" containing information under the categories: id, product_id, quantity and added_date.
id | product_id | quantity | added_date |
---|---|---|---|
1 | 1 | 100 | 2023-04-20 |
2 | 2 | 15 | 2023-05-16 |
3 | 3 | 20 | 2023-05-01 |
4 | 4 | 100 | 2023-05-05 |
Now we will add 2 days to product added_date.
Utilizing the DATE_ADD() function is required. Below is the corresponding query:
SELECT product_id,DATE_ADD(added_date, INTERVAL 2 DAY) AS later_date FROM inventory;
Output:
product_id | later_date |
---|---|
1 | 2023-04-22 |
2 | 2023-05-18 |
3 | 2023-05-03 |
4 | 2023-05-07 |
To raise a particular date in a MySQL database, employ the DATE_ADD() function. Our instance involved raising every starting date by a couple of days.
When doing the coding feels extremely stressed out, we give some advice that will help you reduce yo...
Read ItCSS or Cascading Style Sheets have become a really popular programming language in recent times and...
Read It