How to Add Days to a Date in SQL

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.

idproduct_idquantityadded_date
111002023-04-20
22152023-05-16
33202023-05-01
441002023-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_idlater_date
12023-04-22
22023-05-18
32023-05-03
42023-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.
 


How Can You Avoid Stress...

When doing the coding feels extremely stressed out, we give some advice that will help you reduce yo...

Read It

An Introduction To CSS Pr...

CSS or Cascading Style Sheets have become a really popular programming language in recent times and...

Read It



----Advertisement----