MySQL Forums
Forum List  »  Newbie

datediff
Posted by: ifa thenb
Date: June 23, 2012 04:41PM

My problem:

I need to calculate total days all clients are admitted to a clinic including those clients not yet dischaged. The columns are:

id, discharge_date, admission_date

For clients not yet discharged, the discharge_date value = "null" So I need to replace all null values with "current_date" to calculate total days admitted so far. How do I include this with the query below to get a report that includes number of days admitted for all patients.

My query so far:

SELECT id, discharge_date, admission_date, DATEDIFF (discharge_date,admission_date)+(1) AS 'days_admitted');
FROM ADMIT_Hx

[the +(1) is to include the day of admission thus
DATEDIFF('2012-01-20','2012-01-10')+(1) = 11 days]


Thanks

Options: ReplyQuote


Subject
Written By
Posted
datediff
June 23, 2012 04:41PM
June 23, 2012 07:53PM
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.