MySQL 日期加减函数汇总


当前第2页 返回上一页

为日期减去指定秒数

1

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

5. subdate()  

与adddate()函数用法一致,有两种用法,第二个参数直接填数字的话是为日期减去指定天数,填interval的话是为日期减去指定的interval时间

1

2

3

4

5

6

7

8

9

10

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时间作为参数

1

2

3

4

5

6

7

8

9

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什么情况下会死锁

怎么查看mysql数据库表结构图

如何停止mysql服务器

如何在mysql中创建和删除数据库

mysql 百万级分页优化(mysql千万级快速分页)

mysql notifier是什么?

mysql中常用函数的总结

详解mysql中union的用法

mysql查询连续记录方式

mysql神器之show full processlist

更多相关阅读请进入《mysql》频道 >>


数据库系统概念 第6版
书籍

数据库系统概念 第6版

机械工业出版社

本书主要讲述了数据模型、基于对象的数据库和XML、数据存储和查询、事务管理、体系结构等方面的内容。



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...