如何仅在 codeigniter 中显示从今天的日期和月份到接下来 3 个月的数据?
How to display data from today's date and month to the next 3 months only in codeigniter?
所以,我有即将到期的员工合同数据,我想显示未来 3 个月的今天月份和日期的员工数据。我试过使用 DATEADD 或 DATE_ADD 但它仍然不起作用。请帮助
这是我的查询:
SELECT a.fullname, a.employee_id, a.id_number, b.date_contract_from, b.date_contract_to AS expired,
b.is_current, b.is_deleted, b.employment_status
FROM hr_employees a
INNER JOIN hr_employee_jobs b
ON a.id = b.employee
WHERE b.date_contract_to >= NOW()
AND b.employment_status IN ('1', '2')
AND b.is_current = 1
AND b.is_deleted = 0 AND a.is_deleted = 0
GROUP BY b.employee
ORDER BY b.date_contract_to ASC
这是它的外观示例。所以,4月份的到期日应该不会出现。
this is the query view
您可以像这样使用日期 between in your Query and DATE_ADD 函数。
SELECT a.fullname, a.employee_id, a.id_number, b.date_contract_from, b.date_contract_to AS expired,
b.is_current, b.is_deleted, b.employment_status
FROM hr_employees a
INNER JOIN hr_employee_jobs b
ON a.id = b.employee
WHERE b.date_contract_to BETWEEN now() AND DATE_ADD(now(), INTERVAL 3 MONTH)
AND b.employment_status IN ('1', '2')
AND b.is_current = 1
AND b.is_deleted = 0 AND a.is_deleted = 0
GROUP BY b.employee
ORDER BY b.date_contract_to ASC
所以,我有即将到期的员工合同数据,我想显示未来 3 个月的今天月份和日期的员工数据。我试过使用 DATEADD 或 DATE_ADD 但它仍然不起作用。请帮助
这是我的查询:
SELECT a.fullname, a.employee_id, a.id_number, b.date_contract_from, b.date_contract_to AS expired,
b.is_current, b.is_deleted, b.employment_status
FROM hr_employees a
INNER JOIN hr_employee_jobs b
ON a.id = b.employee
WHERE b.date_contract_to >= NOW()
AND b.employment_status IN ('1', '2')
AND b.is_current = 1
AND b.is_deleted = 0 AND a.is_deleted = 0
GROUP BY b.employee
ORDER BY b.date_contract_to ASC
这是它的外观示例。所以,4月份的到期日应该不会出现。
this is the query view
您可以像这样使用日期 between in your Query and DATE_ADD 函数。
SELECT a.fullname, a.employee_id, a.id_number, b.date_contract_from, b.date_contract_to AS expired,
b.is_current, b.is_deleted, b.employment_status
FROM hr_employees a
INNER JOIN hr_employee_jobs b
ON a.id = b.employee
WHERE b.date_contract_to BETWEEN now() AND DATE_ADD(now(), INTERVAL 3 MONTH)
AND b.employment_status IN ('1', '2')
AND b.is_current = 1
AND b.is_deleted = 0 AND a.is_deleted = 0
GROUP BY b.employee
ORDER BY b.date_contract_to ASC