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

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

MySQL日期加減函數詳解

瀏覽:46日期: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 數據庫
相關文章:
主站蜘蛛池模板: 西青区| 理塘县| 甘肃省| 青州市| 沭阳县| 泰安市| 永福县| 西城区| 兴仁县| 桐城市| 沙雅县| 焦作市| 瑞昌市| 长海县| 垫江县| 漳平市| 宜丰县| 余庆县| 东乌珠穆沁旗| 昆山市| 兴仁县| 旬阳县| 东阿县| 布拖县| 股票| 恩平市| 麻江县| 罗城| 新绛县| 铅山县| 铜山县| 五河县| 大兴区| 读书| 安顺市| 普兰店市| 紫金县| 廊坊市| 北京市| 南康市| 阿图什市|