1

我有一个 JD Edwards 表列,其值 170443 代表时间。我想将其格式化为 HH:MI:SS 但我收到错误 ORA-01850: hour must be between 0 and 23. 我需要对以下代码应用哪些更改才能使输出显示为 17: 04:43?

SELECT CASE WHEN LVUPMT= 0 THEN NULL 
  ELSE
    TO_TIMESTAMP(substr(LVUPMT,1,2) ||':'||substr(LVUPMT,3,2) ||':'||substr(LVUPMT,5,2), 'HH24:MI:SS')
  END AS DDATE 
FROM PRODDTA.F07620 WHERE LVAN8 = 102366;
4

1 回答 1

0

使用适合您数据格式的掩码将其转换为日期,然后将其转换为 tsring 以获得您想要的格式:

SELECT CASE WHEN LVUPMT= 0 THEN NULL 
  ELSE
    to_char( to_date(LVUPMT, 'HH24MISS'), 'HH24:MI:SS')
  END AS DDATE 
FROM PRODDTA.F07620 WHERE LVAN8 = 102366;
于 2019-05-13T14:19:52.163 回答