mysql获取当前日期与合同到期日期差小于1个月的非离职员工

sql:

SELECT
	DATEDIFF(CURDATE(), a.expire_date) AS diff_daoqi_date
FROM
	`ys_admin_user` as a
WHERE 1
AND a.if_del = 0
AND (
	(
		DATEDIFF(CURDATE(), a.expire_date) < 30
		AND DATEDIFF(CURDATE(), a.expire_date) >= 0
	)
	OR (
		DATEDIFF(CURDATE(), a.expire_date) < 0
		AND DATEDIFF(CURDATE(), a.expire_date) > - 30
	)
);

数据:

mysql获取当前日期与合同到期日期差小于1个月的非离职员工_第1张图片

你可能感兴趣的:(mysql,数据库)