SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Datediff help
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

reedallenbrown
Starting Member

USA
2 Posts

Posted - 01/12/2013 :  12:07:17  Show Profile  Reply with Quote
I just can't seem to figure this out. I'm trying to get the number of days between two fields. Field one is named "startofcare" and field two is named "dischargeddate". Using the formula below works fine unless the discharge date is blank meaning the Patient has not left service yet. I still need to know the date difference from the startofcare to today. can I do both in one formula?


(datediff(day,[startofcare],[dischargedate]))

I thought I could use (datediff(day,[startofcare],[dischargedate])) .OR. (datediff(day,[startofcare],GETDATE))

but that does not work.

Any idea's????

Thanks so much for the help.

visakh16
Very Important crosS Applying yaK Herder

India
52325 Posts

Posted - 01/12/2013 :  12:33:06  Show Profile  Reply with Quote
datediff(day,[startofcare],COALESCE(NULLIF([dischargedate],''),GETDATE()))

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

reedallenbrown
Starting Member

USA
2 Posts

Posted - 01/12/2013 :  12:53:50  Show Profile  Reply with Quote
Thank you so much that worked !!!!!
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
52325 Posts

Posted - 01/12/2013 :  12:57:24  Show Profile  Reply with Quote
welcome

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.06 seconds. Powered By: Snitz Forums 2000