Oracle 日期格式化空日期为 00/00/0000
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4586014/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Oracle Date Formatting Null date as 00/00/0000
提问by msbyuva
How can I format the Null Dates in my Oracle SQL to 00/00/0000. I am using NVL function but it doesn't recognize the 00/00/0000 as the date format.
如何将 Oracle SQL 中的空日期格式化为 00/00/0000。我正在使用 NVL 函数,但它无法将 00/00/0000 识别为日期格式。
Is there any Date Formatting available in Oracle SQL which formats null date to 00/00/0000
Oracle SQL 中是否有任何可用的日期格式将空日期格式化为 00/00/0000
回答by DwB
Do the to_char first and wrap it in the NVL. For example,
首先执行 to_char 并将其包装在 NVL 中。例如,
select nvl(to_char(null, 'DD-MM-YYYY'), '00-00-0000') from dual
回答by Majid Hasan
Use this function to assign default values of null values of date:
使用此函数分配日期的空值的默认值:
SELECT id, NVL(start_date, to_date('20020101','YYYYMMDD')) FROM employee;