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

 

相关文章:

  • 2021-11-17
  • 2021-07-01
  • 2021-05-26
  • 2022-12-23
  • 2021-09-27
  • 2021-12-26
  • 2022-12-23
  • 2021-12-31
猜你喜欢
  • 2022-12-23
  • 2021-12-15
  • 2022-12-23
  • 2022-12-23
  • 2021-12-26
  • 2021-11-25
  • 2022-02-03
相关资源
相似解决方案