博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
mysql 日期计算总结
阅读量:4029 次
发布时间:2019-05-24

本文共 401 字,大约阅读时间需要 1 分钟。

日期相加:date_add() 例如:select DATE_ADD(now(),INTERVAL 1 week)--->意思是当前日期加一周的日期。比如当前日期为2018/01/04那么此条语句返回的数据为2018/01/11

日期相加:date_sub() 例如:select date_sub(now(),INTERVAL 1 week)--->意思是当前日期减一周的日期。比如当前日期为2018/01/11那么此条语句返回的数据为2018/01/04

两个日期相减返回天数:DATEDIFF()例如:select DATEDIFF(current_date(),'2018-01-03')例如当前时间为2018-01-04那么此条数据返回为1天

date_format 时间格式化,用法可以精确获取年月日时分秒例如:select date_format (now(),'%Y')--->2018

转载地址:http://tqvbi.baihongyu.com/

你可能感兴趣的文章
网页设计里的浮动 属性
查看>>
Maximum Subsequence Sum
查看>>
PTA:一元多项式的加乘运算
查看>>
CCF 分蛋糕
查看>>
解决python2.7中UnicodeEncodeError
查看>>
小谈python 输出
查看>>
Django objects.all()、objects.get()与objects.filter()之间的区别介绍
查看>>
python:如何将excel文件转化成CSV格式
查看>>
Django 的Error: [Errno 10013]错误
查看>>
机器学习实战之决策树(一)
查看>>
[LeetCode By Python] 2 Add Two Number
查看>>
python 中的 if __name__=='__main__' 作用
查看>>
机器学习实战之决策树二
查看>>
[LeetCode By Python]7 Reverse Integer
查看>>
[LeetCode By Python]9. Palindrome Number
查看>>
[leetCode By Python] 14. Longest Common Prefix
查看>>
[LeetCode By Python]107. Binary Tree Level Order Traversal II
查看>>
[LeetCode By Python]108. Convert Sorted Array to Binary Search Tree
查看>>
[leetCode By Python]111. Minimum Depth of Binary Tree
查看>>
[LeetCode By Python]118. Pascal's Triangle
查看>>