Mysql timestamp default value

database, mysql

Solution

Nope you cannot do this

DEFAULT ADDDATE(CURRENT_TIMESTAMP, INTERVAL 20 MINUTE),

explanation from the manual :

The DEFAULT value clause in a data type specification indicates a default value for a column. With one exception, the default value must be a constant; it cannot be a function or an expression.

Must be a constant not a function ...

Problem

Am really new to Mysql. Is it possible to do something like the following in some way? Mysql throws a syntax error as expected but is there something that I should change that would make it work? ``` CREATE TABLE tracksession(ID INT NOT NULL AUTO_INCREMENT, user_id INT DEFAULT NULL, leave_mode ENUM('loggedout', 'timedout') DEFAULT NULL, login TIMESTAMP DEFAULT CURRENT_TIMESTAMP, logout TIMESTAMP DEFAULT ADDDATE(CURRENT_TIMESTAMP, INTERVAL 20 MINUTE), PRIMARY KEY(ID)); ``` Thanks in advance.

Original source