如何在 MySQL 查詢中給 DATETIME 欄位新增一天?


藉助 DATE_ADD() 函式,我們可以在表的 DATETIME 欄位中新增一天。

mysql> Select StudentName, RegDate, Date_ADD(RegDate, INTERVAL +1 day) AS 'NEXT DAY'
       from testing where StudentName = 'gaurav';

+-------------+---------------------+---------------------+
| StudentName | RegDate             | NEXT DAY            |
+-------------+---------------------+---------------------+
| Gaurav      | 2017-10-29 08:48:33 | 2017-10-30 08:48:33 |
+-------------+---------------------+---------------------+
1 row in set (0.00 sec)

上述查詢將在名為“testing”的 MySQL 表中,位於 StudentName 為 Gaurav 的 RegDate 中新增一天。

更新日期:29-1-2020

2K+ 瀏覽量

啟動你的 職業生涯

透過完成課程獲取認證

開始學習
Advertisement
© . All rights reserved.