有两种方式可以获得mysql两个日期之间的差值,一种是使用TO_DAYS函数,另一种是datediff函数
select id,
TO_DAYS(NOW()) - TO_DAYS(createTime) as dayFactor,
datediff(NOW(),createTime) as dayFactor1
from code_snippet
limit 10
上面的sql中的code_snippet表中有字段id和createTime。
原创文章,作者:奋斗,如若转载,请注明出处:https://blog.ytso.com/tech/database/6654.html