MySQL Forums
Forum List  »  Newbie

Re: datediff
Posted by: ifa thenb
Date: June 24, 2012 11:51AM

Hi Peter

This worked perfectly. Thanks

One part of the query I don't understand:

How does the DATEFIFF function serve both the IFNULL statement as well as the outside or broader statement.


The IFNULL statement tells mysql to calculated the difference between two dates whenever the dischared date is null, but how does it know to do the same for when the discharge_date is not null? If I remove the IFNULL statement I get:

1+ DateDiff (,admissin_date)
1 + DateDiff( ), admission date )

so somehow, the 1 + DateDiff( IfNull( discharge_date, CurDate() ) portion of the statement is serving both the IFNULL and broader statement

Paul

Options: ReplyQuote


Subject
Written By
Posted
June 23, 2012 04:41PM
June 23, 2012 07:53PM
Re: datediff
June 24, 2012 11:51AM
June 24, 2012 12:18PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.