How to create a Custom Field evaluating a blank date field

How to create a Custom Field evaluating a blank date field

I want to setup a custom formula which will convert the difference between dates (i.e. calculate a conversion date). The Formula will check if a Date B exists and if it does return Date A - Date B, else will return Date A - Date C.

Date A - Invoice Date
Date B - 30 Day Trial Date
Date C - Inquiry Date

Formula Return Type = Number

I have set this up as such:
If(Accounts.30 Day Trial Date Setup =! null, (Datecomp(${Accounts.Invoice Date},${Accounts.30 Day Trial Date Setup}))/1440, (Datecomp(${Accounts.Invoice Date},${Accounts.Inquiry Date}))/1440)

No matter what I keep trying I keep getting an invalid argument error.  I believe this is because the If statement is checking a Date field, however the formula returns a Number.

Can you please provide a solution/workaround?

Thank you, 
Susan