因此,我尝试根据日期是否位于两个日期范围之间来更新表格,而不是如果日期超出两个范围则更新字段,而不是更新字段
update tablex
set field = 1
where tableid = 1
and to_date('10/14/2024', 'mm/dd/yyyy') not between trunc(sysdate) and trunc(sysdate - 15);
这是否应该跳过更新字段,因为 10/14/24 日期介于
sysdate
和 sysdate-15
(9/30/2024)
之间?
您的“to_date('10/14/2024', 'mm/dd/yyyy')”格式似乎不正确。
如果包含日期的列已经采用日期格式,您需要执行以下操作:
-- 将 your_date_column 替换为正确的列名称 --
update tablex
set field = 1
where tableid = 1
and (your_date_column not between trunc(sysdate - 15) and trunc(sysdate));
如果包含日期的列不是日期格式,您需要执行以下操作:
-- 将 your_date_column 替换为正确的列名称 --
update tablex
set field = 1
where tableid = 1
and (to_date(your_date_column, 'MM/DD/YYYY') not between trunc(sysdate - 15) and trunc(sysdate));