8

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

Cœur
  • 37,241
  • 25
  • 195
  • 267
msbyuva
  • 3,467
  • 13
  • 63
  • 87

3 Answers3

20

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
DwB
  • 37,124
  • 11
  • 56
  • 82
1

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

SELECT id, NVL(start_date, to_date('20020101','YYYYMMDD')) FROM employee;
Dharman
  • 30,962
  • 25
  • 85
  • 135
0
select * from mty_containers mt  where terminal_id=1
and (
    in_date>=decode(to_date('','dd/mm/yyyy'),'',mt.in_date,to_date('','dd/mm/yyyy'))
     or  (case when '' is null  then nvl(to_char(in_date,'dd/mm/yyyy'),'N') End ='N' )
     )
and 
   (
     in_date<=decode(to_date('','dd/mm/yyyy'),'',mt.in_date,to_date('','dd/mm/yyyy'))
     or  (case when '' is null  then nvl(to_char(in_date,'dd/mm/yyyy'),'N') End ='N' )
   )
Suraj Rao
  • 29,388
  • 11
  • 94
  • 103
  • Date fillter when from and to data is avialable then show only those records other wise all record will show – Devendra Giri Nov 29 '21 at 12:06
  • 1
    Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Nov 29 '21 at 12:45