[ACCEPTED]-Insert timestamp into a database + 7 days-sql
Accepted answer
There are a number of date/time functions 5 in MySQL that will do the trick here.
http://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html#function_date-add
registration_expires=DATE_ADD(NOW(), INTERVAL 7 DAY)
You 4 can't set an expression as a default, though 3 - you'll need to do it in your INSERT queries. Notice 2 that even if your expr value is > 1 there 1 is no plural used for the unit value.
Or you could create a view from a query 2 where you add the interval, or when you 1 query the db always add the 7 days interval.
Source:
stackoverflow.com
More Related questions
Cookie Warning
We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.