如何在MySQL中设置未来日期
我正在创建一个具有3列的表,一个主键ID
另一个reg_date
保留用户已注册的日期和最后一个exp_date 比
reg_date
提前4年以保留帐户的到期日期。
如何将exp_date
设置为reg_date
+ 4年?
这是我到目前为止写的代码:
CREATE TABLE Accounts (
id INT(6) UNSIGNED AUTO_INCREMENT PRIMARY KEY,
reg_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
exp_date TIMESTAMP
)
I am creating a table that has 3 columns one primary key id
the other one reg_date
to hold the date that the user has registered and the last one exp_date
which is 4 years ahead of reg_date
to hold the expiry date of the account.
How can I set the exp_date
to reg_date
+ 4 years?
Here's the code I've written so far:
CREATE TABLE Accounts (
id INT(6) UNSIGNED AUTO_INCREMENT PRIMARY KEY,
reg_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
exp_date TIMESTAMP
)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试这样做,
Try this way,