国产成人精品亚洲777人妖,欧美日韩精品一区视频,最新亚洲国产,国产乱码精品一区二区亚洲

您的位置:首頁技術(shù)文章
文章詳情頁

MySQL日期加減函數(shù)詳解

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

1. addtime()  

為日期加上指定秒數(shù)

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

2. adddate()  

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

select adddate(now(),1); -- 加1天select adddate(now(), interval 1 day); -- 加1天select adddate(now(), interval 1 hour); --加1小時(shí)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()

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

select date_add(now(), interval 1 day); -- 加1天select date_add(now(), interval 1 hour); -- 加1小時(shí)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()

為日期減去指定秒數(shù)

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

5. subdate()

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

select subdate(now(),1); -- 減1天select subdate(now(), interval 1 day); -- 減1天select subdate(now(), interval 1 hour); --減1小時(shí)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()函數(shù)用法一致,為日期減去一個(gè)時(shí)間間隔,這個(gè)只能使用interval時(shí)間作為參數(shù)

select date_sub(now(), interval 1 day); -- 減1天select date_sub(now(), interval 1 hour); --減1小時(shí)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年

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

標(biāo)簽: MySQL 數(shù)據(jù)庫
相關(guān)文章:
主站蜘蛛池模板: 福泉市| 新昌县| 汤阴县| 民乐县| 阜新市| 永泰县| 宝丰县| 江孜县| 简阳市| 石楼县| 子洲县| 连城县| 济宁市| 舟曲县| 泰安市| 湘西| 濮阳市| 阆中市| 古蔺县| 丹寨县| 西宁市| 泽库县| 通道| 大埔县| 甘德县| 太谷县| 高雄县| 城市| 黄平县| 于田县| 宣城市| 平武县| 平谷区| 屏山县| 巩留县| 浦城县| 洛隆县| 印江| 噶尔县| 青龙| 雅安市|