[英]How to get months duration between two dates in mysql?
select datediff (curdate(), hire_date ) as diff
from emp
order by hire_date asc;
But, this does not give the output in months, how to get it in months?但是,这在几个月内不给output,如何在几个月内得到它?
try something like: SELECT DATEDIFF(month, curdate(), hire_date) AS diff
尝试类似:
SELECT DATEDIFF(month, curdate(), hire_date) AS diff
You can you Timestamp in MySQL您可以在 MySQL 中添加时间戳
SELECT TIMESTAMPDIFF(MONTH,curdate(),hire_date);
For SQL Server适用于 SQL 服务器
SELECT DATEDIFF(month, curdate(), hire_date) AS DateDiff;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.