Extracting SQL DATE from a column

Schedule table I have a table "schedule" and a column "travel_date". In this case, travel_date has a "predefined date".

I want to change this column with "5 days".

as

UPDATE Schedule SET travel_date=''+5days ;

      

I used UPDATE schedule SET travel_date = (travel_date + 5); Did it work?

+3


source to share


4 answers


In MySQL, you can do this with



UPDATE  customer
SET     register_date = DATE_ADD(register_date, INTERVAL 5 DAY)

      

+2


source


Why do you want to add 5 days to each customer account ????

Are you sure this is what you want to do?



UPDATE customer SET [register_date] = DATE_ADD([register_date], INTERVAL 5 DAY)

      

+1


source


If it is a datetime column use the function DATE_ADD()

:

UPDATE customer SET register_date = DATE_ADD(register_date, INTERVAL 5 DAY)

0


source


Using DATE_ADD()

You can use a function DATE_ADD()

to handle adding a given interval (e.g. days, minutes, hours, etc.) to an existing date column:

UPDATE customer
   SET register_date = DATE_ADD(register_date, INTERVAL 5 DAY)

      

Using date arithmetic

Alternatively, you can simply use date arithmetic, which is similar to the previous example:

UPDATE customer
   SET register_date = register_date + INTERVAL 5 DAY

      

0


source







All Articles