How to add some amount of time from now?(MySQL)

Problem :

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.

Solution :

I think 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

Mysql Tutorials

Mysql Howto..

How to store special characters (', ", &, etc) in mysql database, so they can be searchable?

how to round mysql column in a table output

MySQL Date Issue - how to compute?

How to add 0's infront with auto increment in a mysql database

Apache2 process never ending - how do I determine why?

How to get values from listview android?

Java / MySQL - How to access connection from another class?

how to get the exactly mysql query of unbook rooms in hotel booking system?

How to use one argument repeatedly in mysql query (NODE.js)

How to output mysql multiline data in the same format with PHP and HTML?

How to find similar results from all rows in DB with MySQL query

mysql query, how to go about it?

How to migrate from ms sql to mysql

How to interface a java application with a local database in Mac os x

How to sort a table by time column in Mysql/Sql?

how to create role on MySQL database

How to use async Mysql query with PHP PDO

How to connect Apache Solr with mysql

Taking two tables, 1-to-many, how can I filter down the many table and then join ALL the matches in the 1 table?

how to write case statement in mysql?

Using SVN with a MySQL database ran by xamp - yes or no? (and how?)

How can Android apps access MySQL? [closed]

How to store the value of a MySQL subquery and use it in the WHERE clause of the outter query

How to count the number of (number of duplicates) in a database

How to use MySQL value ins second query?

How to insert and retrieve at the same time in MySQL

How to Select MYSQL datetime column to HTML input datetime

How to create a daily dump in MySQL?

How to display an incremental value that was just created in mysql

How to make a MySQL generated table interactive PHP