Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我必须在数据库中插入一个日期,并且我想在该日期后 2 周设置结束日期。
我怎样才能做到?
在我的选择中,我想需要类似的东西:
insert into table values (current_Date, current_Date+2weeks) where....
但我不知道该怎么做。
对于 mysql
INSERT INTO tbl(fromdate,todate) values (now(), DATE_ADD(now(),INTERVAL 2 WEEK))
对于 sql 服务器
INSERT INTO tbl(fromdate,todate) values( current_timestamp, DATEADD(week,2,current_timestamp))