当我执行以下语句时,日期格式在epc.LAST_LICPLT_REPRINT_DT中丢失:
,CASE When epc.LAST_LICPLT_REPRNT_DT is null Then ''
ELSE '' + epc.LAST_LICPLT_REPRNT_DT
END as LAST_LICPLT_REPRNT_DT
我试过用
cast(epc.LAST_LICPLT_REPRNT_DT as date)
和
cast(epc.LAST_LICPLT_REPRNT_DT as DATE FORMAT 'YYYYMMDD')
幽冥工作。
答案 0 :(得分:0)
SELECT COALESCE(CAST(epc.LAST_LICPLT_RPRNT_DT AS VARCHAR(10)), '') --Return Empty String If Date Null
, COALESCE(epc.LAST_LICPLT_RPRNT_DT, DATE '9999-12-31') -- Return High Date if Date is Null
FROM {MyDB}.{MyTable}
WHERE epc.LAST_LICPLT_RPRNT_DT IS NULL;