我有以下场景:
我有员工登记他们的上班/下班手续。但他们有10分钟的容忍度。
我通过这种观点得到的最新条目:
CREATE OR REPLACE VIEW employees_late_entries
(
id,
created_datetime,
entry_datetime,
contact_id,
contact_name,
user_id,
employees_perm_id
)
AS
SELECT precence_records.id,
precence_records.created AS created_datetime,
("substring"(precence_records.created::text, 0, 11) || ' '::text) || contacts.entry_time::text AS entry_datetime,
contacts.id AS contact_id,
contacts.name AS contact_name,
precence_records.user_id,
precence_records.employees_perm_id
FROM precence_records,
contacts
WHERE
precence_records.type::text = 'entry'::text AND
contacts.employee = true AND
contacts.id = precence_records.contact_id AND
( ("substring"(precence_records.created::text, 0, 11) || ' '::text) || contacts.entry_time::text) < precence_records.created::text AND
precence_records.employees_perm_id IS NULL;
the precence_records.created
是办理入住手续的时间以及contacts.entry_time
它是员工的日程输入时间。
这是condition contacts.entry_time
vs precence_records.created
获取迟到的条目:
( ("substring"(precence_records.created::text, 0, 11) || ' '::text) || contacts.entry_time::text) < precence_records.created::text
所以我想做这样的事情:
( ("substring"(precence_records.created::text, 0, 11) || ' '::text) || (contacts.entry_time::text + 10 MINUTES) ) < precence_records.created::text
数据类型:
precence_records.created 时间戳
contact.entry_time VARCHAR
你能帮我吗