Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Using Greatest function on 2 dates, one can be null
Bricklen wrote:
> Kelly Gallagher wrote: >
> > How about something like this > eg. > select case when to_date(:date1,'DD/MM/YYYY') > > to_date(:date2,'DD/MM/YYYY') or :date2 is null then :date1 else :date2 > end from dual; > > Also depends on Oracle version
Alternatively:
SELECT GREATEST(NVL(date1, TO_DATE(01-JAN-1800')), NVL(date2,
TO_DATE(01-JAN-1800')))
INTO x
FROM dual;
Any chance they could both be NULL?
-- Daniel Morgan http://www.outreach.washington.edu/ext/certificates/oad/oad_crs.asp http://www.outreach.washington.edu/ext/certificates/aoa/aoa_crs.asp damorgan_at_x.washington.edu (replace 'x' with a 'u' to reply)Received on Mon May 17 2004 - 20:08:56 CDT
![]() |
![]() |