sql – MySQL’s now() +1 day

The Question :

217 people think this question is useful

I’m using now() in MySQL query.

INSERT INTO table SET data = '$data', date = now()

But I want to add 1 day to this date (so that date should contain tomorrow).
Is it possible?

The Question Comments :

The Answer 1

465 people think this answer is useful

You can use:

NOW() + INTERVAL 1 DAY

If you are only interested in the date, not the date and time then you can use CURDATE instead of NOW:

CURDATE() + INTERVAL 1 DAY

The Answer 2

8 people think this answer is useful

better use quoted `data` and `date`. AFAIR these may be reserved words my version is:

INSERT INTO `table` ( `data` , `date` ) VALUES('".$date."',NOW()+INTERVAL 1 DAY);

The Answer 3

5 people think this answer is useful

Try doing: INSERT INTO table(data, date) VALUES ('$data', now() + interval 1 day)

The Answer 4

4 people think this answer is useful
INSERT INTO `table` ( `data` , `date` ) VALUES('".$data."',NOW()+INTERVAL 1 DAY);

Add a Comment