MYSQL如何計算兩個日期間隔天數


如何透過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

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM