SELECT
S
-- Db2 for LUW since 11.1
--, DATE (TO_DATE (REGEXP_SUBSTR (T.S, '\d{1,2}/\d{1,2}/\d{4}'), 'DD/MM/YYYY')) AS D1
-- Should work on Db2 for Z/OS as well
, DATE (TO_DATE
(
XMLCAST
(
XMLQUERY ('fn:replace ($D, ".*?([0-9]{1,2}/[0-9]{1,2}/[0-9]{4}).*", "$1")' PASSING T.S AS "D")
AS VARCHAR (10)
)
, 'DD/MM/YYYY'
)) AS D2
FROM
(
SELECT 'My comment with 31/12/2022 date' FROM SYSIBM.SYSDUMMY1
UNION ALL SELECT 'Some date 1/2/2022 here' FROM SYSIBM.SYSDUMMY1
) T (S)
1条答案
按热度按时间6yt4nkrj1#
| 标准|第二天|
| - -|- -|
| 我的评论与31/12/2022日期|2022年12月31日|
| 此处显示的日期为2022年1月2日|2022年2月1日|