如何在Oracle中仅使用日期而不用时间来更新行?

时间:2018-07-12 10:15:39

标签: sql oracle

我的查询是:

UPDATE SHIPMENT 
SET   PRODCODE='LAN', 
      SHIPQTY='39.54',
      REMARKS='MR BOPL',
      MISEQ='-1',
      SITEID='MR',
      SSEMPNO='31111110',
      S_GAUGE='412.54', 
      E_GAUGE='389.50',
      DENSITY='800',
      TEMPERATURE='40.30',
      TEMPATEND='40.30',
      SEDATE=TO_DATE('10-Jul-2018 12:00 AM','dd-Mon-yyyy HH:MI AM'), 
      WEIGHT_S='705.12',
      WEIGHT_E='665.58',
      SEEMPNO='31111110',
      TANKNO='1001' 
WHERE KEYSEQ='60719' 
  AND SSDATE=TO_DATE('09-Jul-2018 12:00 AM','dd-Mon-yyyy HH:MI AM');

有2行具有相同日期和不同时间,但是我想在where条件下仅使用'09-Jul-2018'来更新这两行。有可能吗?

2 个答案:

答案 0 :(得分:1)

使用:

WHERE KEYSEQ='60719' 
  AND SSDATE >= TO_DATE('09-Jul-2018','dd-Mon-yyyy') 
  AND SSDATE < TO_DATE('09-Jul-2018','dd-Mon-yyyy') + 1;

thiw将用日期09-Jul-2018KEYSEQ='60719'更新所有行

答案 1 :(得分:1)

如果我理解得很好,则您需要:

AND trunc(SSDATE) = TO_DATE('09-Jul-2018', 'dd-Mon-yyyy');

或者更好

AND trunc(SSDATE) = date '2018-07-09'