您好,欢迎访问一九零五行业门户网

我们如何在MySQL表的列中存储的日期中添加天/秒?

两个函数可用于此目的,并且在这两个函数中,我们需要提供列名作为参数以及 interval 关键字。函数如下 -
date_add() 函数该函数的语法为 date_add(date, interval 表达式单元)。可以通过使用表“collegedetail”中的数据的示例来演示 -
mysql> select estb, date_add(estb, interval 10 day) from collegedetail;+------------+---------------------------------+| estb | date_add(estb, interval 10 day) |+------------+---------------------------------+| 2010-05-01 | 2010-05-11 || 1995-10-25 | 1995-11-04 || 1994-09-25 | 1994-10-05 || 2001-07-23 | 2001-08-02 || 2010-07-30 | 2010-08-09 |+------------+---------------------------------+5 rows in set (0.00 sec)
上述查询在 'collegedetail' 表的 'estb' 列中存储的日期添加了 10 天。
adddate() 函数该函数的语法为adddate(日期, interval 表达式单元)。可以通过使用表“collegedetail”中的数据的示例来演示 -
mysql> select estb, adddate(estb, interval 10 day) from collegedetail;+------------+--------------------------------+| estb | adddate(estb, interval 10 day) |+------------+--------------------------------+| 2010-05-01 | 2010-05-11 || 1995-10-25 | 1995-11-04 || 1994-09-25 | 1994-10-05 || 2001-07-23 | 2001-08-02 || 2010-07-30 | 2010-08-09 |+------------+--------------------------------+5 rows in set (0.00 sec)
上述查询在“collegedetail”表的“estb”列中存储的日期中添加了 10 天。
以上就是我们如何在mysql表的列中存储的日期中添加天/秒?的详细内容。
其它类似信息

推荐信息