How to add some amount of time from now?(MySQL)
How can I add certain amount of time from now in mysql?
INSERT INTO rank(id, username, rank_type, time_start, time_end, activated) VALUES (NULL, 'somename', 1, NOW(), DATE(NOW() + INTERVAL 30 DAY), 0);
It says syntax error. I think the problem is caused by DATE function. Also tried to use NOW() + INTERVAL 30 DAY, but it didn't work either.
DATE_ADD(date,INTERVAL expr type) is what you are looking for..
INSERT INTO rank(id, username, rank_type, time_start, time_end, activated) VALUES (NULL, 'somename', 1, NOW(), DATE_ADD(NOW(), INTERVAL 30 DAY),0);
Some documentation can be found here
Here is an SQLFiddle
- A Linux, Apache, MySQL, PHP (LAMP) stack is a combination of open source software that is typically installed together to enable a server to host dynamic […]
- MySQL is an the most popular open-source database management system, in most of hosting company its has been bundle by LAMP(Linux, Apache, MySQL, PHP/Python/Perl) stack. Another alternative […]
- MySQL is the world’s most popular open-source database. Despite its powerful features, MySQL is simple to set up and easy to use. Below are some instructions […]