如何透過MYSQL自帶函數計算給定的兩個日期的間隔天數
有兩個途徑可獲得
1、利用TO_DAYS函數
select to_days(now()) - to_days('20120512')
2、利用DATEDIFF函數
select datediff(now(),'20120512')
參數1 - 參數2 等於間隔天數
select (datediff(curdate(), date(colunm_name1))- (select colunm_name2 from table_name2)) as o from table_name1
------------------------------------
轉自:https://blog.csdn.net/lixiang212121/article/details/30038127