久久r热视频,国产午夜精品一区二区三区视频,亚洲精品自拍偷拍,欧美日韩精品二区

您的位置:首頁技術文章
文章詳情頁

MySQL日期加減函數詳解

瀏覽:72日期:2023-10-14 18:36:13

1. addtime()  

為日期加上指定秒數

select addtime(now(),1); -- 加1秒

2. adddate()  

有兩種用法,第二個參數直接填數字的話是為日期加上指定天數,填interval的話是為日期加上指定的interval時間

select adddate(now(),1); -- 加1天select adddate(now(), interval 1 day); -- 加1天select adddate(now(), interval 1 hour); --加1小時select adddate(now(), interval 1 minute); -- 加1分鐘select adddate(now(), interval 1 second); -- 加1秒select adddate(now(), interval 1 microsecond); -- 加1毫秒select adddate(now(), interval 1 week); -- 加1周select adddate(now(), interval 1 month); -- 加1月select adddate(now(), interval 1 quarter); -- 加1季select adddate(now(), interval 1 year); -- 加1年

3. date_add()

為日期增加一個時間間隔,這個只能使用interval時間作為參數,用法和adddate()一致

select date_add(now(), interval 1 day); -- 加1天select date_add(now(), interval 1 hour); -- 加1小時select date_add(now(), interval 1 minute); -- 加1分鐘select date_add(now(), interval 1 second); -- 加1秒select date_add(now(), interval 1 microsecond); -- 加1毫秒select date_add(now(), interval 1 week); -- 加1周select date_add(now(), interval 1 month); -- 加1月select date_add(now(), interval 1 quarter); -- 加1季select date_add(now(), interval 1 year); -- 加1年

4. subtime()

為日期減去指定秒數

select subtime(now(), 1); -- 減1秒

5. subdate()

與adddate()函數用法一致,有兩種用法,第二個參數直接填數字的話是為日期減去指定天數,填interval的話是為日期減去指定的interval時間

select subdate(now(),1); -- 減1天select subdate(now(), interval 1 day); -- 減1天select subdate(now(), interval 1 hour); --減1小時select subdate(now(), interval 1 minute); -- 減1分鐘select subdate(now(), interval 1 second); -- 減1秒select subdate(now(), interval 1 microsecond); -- 減1毫秒select subdate(now(), interval 1 week); -- 減1周select subdate(now(), interval 1 month); -- 減1月select subdate(now(), interval 1 quarter); -- 減1季select subdate(now(), interval 1 year); -- 減1年

6. date_sub()   

與date_add()函數用法一致,為日期減去一個時間間隔,這個只能使用interval時間作為參數

select date_sub(now(), interval 1 day); -- 減1天select date_sub(now(), interval 1 hour); --減1小時select date_sub(now(), interval 1 minute); -- 減1分鐘select date_sub(now(), interval 1 second); -- 減1秒select date_sub(now(), interval 1 microsecond); -- 減1毫秒select date_sub(now(), interval 1 week); -- 減1周select date_sub(now(), interval 1 month); -- 減1月select date_sub(now(), interval 1 quarter); -- 減1季select date_sub(now(), interval 1 year); -- 減1年

到此這篇關于MySQL日期加減函數詳解的文章就介紹到這了,更多相關MySQL日期加減函數匯總內容請搜索好吧啦網以前的文章或繼續瀏覽下面的相關文章希望大家以后多多支持好吧啦網!

標簽: MySQL 數據庫
相關文章:
主站蜘蛛池模板: 土默特左旗| 三江| 宁蒗| 固原市| 石景山区| 祁东县| 平舆县| 怀远县| 邯郸县| 疏勒县| 吴川市| 乐亭县| 蒙阴县| 襄垣县| 湾仔区| 赣州市| 资阳市| 武川县| 毕节市| 灌云县| 昌都县| 巴彦县| 靖江市| 林州市| 大冶市| 兴仁县| 孟村| 阿图什市| 双牌县| 招远市| 微山县| 通许县| 泗阳县| 文化| 龙里县| 凤阳县| 平谷区| 越西县| 宜宾市| 永春县| 新营市|