Oracle Date Formatting Null date as 00/00/0000

我的未来我决定 提交于 2019-12-22 04:45:23

问题


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.

Is there any Date Formatting available in Oracle SQL which formats null date to 00/00/0000


回答1:


Do the to_char first and wrap it in the NVL. For example,

select nvl(to_char(null, 'DD-MM-YYYY'), '00-00-0000') from dual



回答2:


Use this function to assign default values of null values of date:

SELECT id, NVL(start_date, to_date('20020101','YYYYMMDD')) FROM employee;


来源:https://stackoverflow.com/questions/4586014/oracle-date-formatting-null-date-as-00-00-0000

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!